]> granicus.if.org Git - clang/log
clang
6 years ago[analyzer] [tests] Add an option for showing statistics after running tests.
George Karpenkov [Mon, 30 Jul 2018 23:01:47 +0000 (23:01 +0000)]
[analyzer] [tests] Add an option for showing statistics after running tests.

Do not show statistics by default.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338323 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[analyzer] [tests] Style fixes for testing harness.
George Karpenkov [Mon, 30 Jul 2018 23:01:20 +0000 (23:01 +0000)]
[analyzer] [tests] Style fixes for testing harness.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338322 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoFix use of uninitialized variable in r338299
Scott Linder [Mon, 30 Jul 2018 22:52:07 +0000 (22:52 +0000)]
Fix use of uninitialized variable in r338299

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338321 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[analyzer] [NFC] Simplify some visitors by giving a convenient getter from state...
George Karpenkov [Mon, 30 Jul 2018 22:18:47 +0000 (22:18 +0000)]
[analyzer] [NFC] Simplify some visitors by giving a convenient getter from state to analysis manager

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338315 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[analyzer] Bugfix for autorelease + main run loop leak checker
George Karpenkov [Mon, 30 Jul 2018 22:18:21 +0000 (22:18 +0000)]
[analyzer] Bugfix for autorelease + main run loop leak checker

Do not warn when the other message-send-expression is correctly wrapped
in a different autorelease pool.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338314 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[analyzer] Fix crash in RunLoopAutoreleaseChecker on empty children
George Karpenkov [Mon, 30 Jul 2018 21:44:15 +0000 (21:44 +0000)]
[analyzer] Fix crash in RunLoopAutoreleaseChecker on empty children

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338312 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[docs] UndefinedBehaviorSanitizer.rst: {,un}signed-integer-overflow: tune docs
Roman Lebedev [Mon, 30 Jul 2018 21:11:32 +0000 (21:11 +0000)]
[docs] UndefinedBehaviorSanitizer.rst: {,un}signed-integer-overflow: tune docs

Yes, i erroneously assumed that the "after" was meant,
but i was wrong:
> I really meant "performed before", for cases like 4u / -2,
> where -2 is implicitly converted to UINT_MAX - 2 before
> the computation. Conversions that are performed after
> a computation aren't part of the computation at all,
> so I think it's much clearer that they're not in scope
> for this sanitizer.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338306 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoAvoid returning an invalid end source loc
Stephen Kelly [Mon, 30 Jul 2018 20:39:14 +0000 (20:39 +0000)]
Avoid returning an invalid end source loc

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338301 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[DebugInfo][OpenCL] Generate correct block literal debug info for OpenCL
Scott Linder [Mon, 30 Jul 2018 20:31:11 +0000 (20:31 +0000)]
[DebugInfo][OpenCL] Generate correct block literal debug info for OpenCL

OpenCL block literal structs have different fields which are now correctly
identified in the debug info.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338299 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[OpenEmbedded] Fix lib paths for OpenEmbedded targets
Mandeep Singh Grang [Mon, 30 Jul 2018 19:44:13 +0000 (19:44 +0000)]
[OpenEmbedded] Fix lib paths for OpenEmbedded targets

Summary:
The lib paths are not correctly picked up for OpenEmbedded sysroots (like arm-oe-linux-gnueabi) for 2 reasons:

1. OpenEmbedded sysroots are of the form <sysroot>/usr/lib/<triple>/x.y.z. This form is handled in clang but only for Freescale vendor.

2. 64-bit OpenEmbedded sysroots may not have a /usr/lib dir. So they cannot find /usr/lib64 as it is referenced as /usr/lib/../lib64 in clang.

This is a follow-up to the llvm patch: D48861

Reviewers: dlj, rengolin, fedor.sergeev, javed.absar, hfinkel, rsmith

Reviewed By: rsmith

Subscribers: rsmith, kristof.beyls, cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338294 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoRemove trailing space
Fangrui Song [Mon, 30 Jul 2018 19:24:48 +0000 (19:24 +0000)]
Remove trailing space

sed -Ei 's/[[:space:]]+$//' include/**/*.{def,h,td} lib/**/*.{cpp,h}

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338291 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoMake test/Driver/baremetal.cpp work with linkers other than lld
David Greene [Mon, 30 Jul 2018 19:08:20 +0000 (19:08 +0000)]
Make test/Driver/baremetal.cpp work with linkers other than lld

This test fails if clang is configure with, for example, gold as the
default linker. It does not appear that this test really relies on lld
so make the checks accept ld, ld.gold and ld.bfd too.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338290 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[clang][ubsan] Implicit Conversion Sanitizer - integer truncation - clang part
Roman Lebedev [Mon, 30 Jul 2018 18:58:30 +0000 (18:58 +0000)]
[clang][ubsan] Implicit Conversion Sanitizer - integer truncation  - clang part

Summary:
C and C++ are interesting languages. They are statically typed, but weakly.
The implicit conversions are allowed. This is nice, allows to write code
while balancing between getting drowned in everything being convertible,
and nothing being convertible. As usual, this comes with a price:

```
unsigned char store = 0;

bool consume(unsigned int val);

void test(unsigned long val) {
  if (consume(val)) {
    // the 'val' is `unsigned long`, but `consume()` takes `unsigned int`.
    // If their bit widths are different on this platform, the implicit
    // truncation happens. And if that `unsigned long` had a value bigger
    // than UINT_MAX, then you may or may not have a bug.

    // Similarly, integer addition happens on `int`s, so `store` will
    // be promoted to an `int`, the sum calculated (0+768=768),
    // and the result demoted to `unsigned char`, and stored to `store`.
    // In this case, the `store` will still be 0. Again, not always intended.
    store = store + 768; // before addition, 'store' was promoted to int.
  }

  // But yes, sometimes this is intentional.
  // You can either make the conversion explicit
  (void)consume((unsigned int)val);
  // or mask the value so no bits will be *implicitly* lost.
  (void)consume((~((unsigned int)0)) & val);
}
```

Yes, there is a `-Wconversion`` diagnostic group, but first, it is kinda
noisy, since it warns on everything (unlike sanitizers, warning on an
actual issues), and second, there are cases where it does **not** warn.
So a Sanitizer is needed. I don't have any motivational numbers, but i know
i had this kind of problem 10-20 times, and it was never easy to track down.

The logic to detect whether an truncation has happened is pretty simple
if you think about it - https://godbolt.org/g/NEzXbb - basically, just
extend (using the new, not original!, signedness) the 'truncated' value
back to it's original width, and equality-compare it with the original value.

The most non-trivial thing here is the logic to detect whether this
`ImplicitCastExpr` AST node is **actually** an implicit conversion, //or//
part of an explicit cast. Because the explicit casts are modeled as an outer
`ExplicitCastExpr` with some `ImplicitCastExpr`'s as **direct** children.
https://godbolt.org/g/eE1GkJ

Nowadays, we can just use the new `part_of_explicit_cast` flag, which is set
on all the implicitly-added `ImplicitCastExpr`'s of an `ExplicitCastExpr`.
So if that flag is **not** set, then it is an actual implicit conversion.

As you may have noted, this isn't just named `-fsanitize=implicit-integer-truncation`.
There are potentially some more implicit conversions to be warned about.
Namely, implicit conversions that result in sign change; implicit conversion
between different floating point types, or between fp and an integer,
when again, that conversion is lossy.

One thing i know isn't handled is bitfields.

This is a clang part.
The compiler-rt part is D48959.

Fixes [[ https://bugs.llvm.org/show_bug.cgi?id=21530 | PR21530 ]], [[ https://bugs.llvm.org/show_bug.cgi?id=37552 | PR37552 ]], [[ https://bugs.llvm.org/show_bug.cgi?id=35409 | PR35409 ]].
Partially fixes [[ https://bugs.llvm.org/show_bug.cgi?id=9821 | PR9821 ]].
Fixes https://github.com/google/sanitizers/issues/940. (other than sign-changing implicit conversions)

Reviewers: rjmccall, rsmith, samsonov, pcc, vsk, eugenis, efriedma, kcc, erichkeane

Reviewed By: rsmith, vsk, erichkeane

Subscribers: erichkeane, klimek, #sanitizers, aaron.ballman, RKSimon, dtzWill, filcab, danielaustin, ygribov, dvyukov, milianw, mclow.lists, cfe-commits, regehr

Tags: #sanitizers

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338288 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[analyzer] Store ValueDecl in DeclRegion
George Karpenkov [Mon, 30 Jul 2018 18:57:13 +0000 (18:57 +0000)]
[analyzer] Store ValueDecl in DeclRegion

All use cases of DeclRegion actually have ValueDecl there,
and getting the name from declaration comes in very handy.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338286 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoDelete some unreachable AST printing code.
Richard Smith [Mon, 30 Jul 2018 18:05:19 +0000 (18:05 +0000)]
Delete some unreachable AST printing code.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338282 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[ARM, AArch64]: Use unadjusted alignment when passing composites as arguments
Momchil Velikov [Mon, 30 Jul 2018 17:48:23 +0000 (17:48 +0000)]
[ARM, AArch64]: Use unadjusted alignment when passing composites as arguments

The "Procedure Call Procedure Call Standard for the ARMĀ® Architecture"
(https://static.docs.arm.com/ihi0042/f/IHI0042F_aapcs.pdf), specifies that
composite types are passed according to their "natural alignment", i.e. the
alignment before alignment adjustment on the entire composite is applied.

The same applies for AArch64 ABI.

Clang, however, used the adjusted alignment.

GCC already implements the ABI correctly. With this patch Clang becomes
compatible with GCC and passes such arguments in accordance with AAPCS.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338279 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[analyzer] Add missing state transition in IteratorChecker.
Reka Kovacs [Mon, 30 Jul 2018 16:14:59 +0000 (16:14 +0000)]
[analyzer] Add missing state transition in IteratorChecker.

After cleaning up program state maps in `checkDeadSymbols()`,
a transition should be added to generate the new state.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338263 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[analyzer] Add support for more invalidating functions in InnerPointerChecker.
Reka Kovacs [Mon, 30 Jul 2018 15:43:45 +0000 (15:43 +0000)]
[analyzer] Add support for more invalidating functions in InnerPointerChecker.

According to the standard, pointers referring to the elements of a
`basic_string` may be invalidated if they are used as an argument to
any standard library function taking a reference to non-const
`basic_string` as an argument. This patch makes InnerPointerChecker warn
for these cases.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338259 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[CodeComplete] Fix the crash in code completion on access checking
Ilya Biryukov [Mon, 30 Jul 2018 15:19:05 +0000 (15:19 +0000)]
[CodeComplete] Fix the crash in code completion on access checking

Started crashing in r337453. See the added test case for the crash repro.

The fix reverts part of r337453 that causes the crash and does
not actually break anything when reverted.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338255 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[OPENMP] Modify the info about OpenMP support in UsersManual, NFC.
Alexey Bataev [Mon, 30 Jul 2018 14:44:29 +0000 (14:44 +0000)]
[OPENMP] Modify the info about OpenMP support in UsersManual, NFC.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338252 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[mips64][clang] Adjust tests to account for changes in r338239
Stefan Maksimovic [Mon, 30 Jul 2018 12:27:40 +0000 (12:27 +0000)]
[mips64][clang] Adjust tests to account for changes in r338239

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338246 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[clang-format] Silence -Wdocumentation warnings
Krasimir Georgiev [Mon, 30 Jul 2018 12:22:41 +0000 (12:22 +0000)]
[clang-format] Silence -Wdocumentation warnings

introduced in r338232

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338245 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[mips64][clang] Provide the signext attribute for i32 return values
Stefan Maksimovic [Mon, 30 Jul 2018 10:44:46 +0000 (10:44 +0000)]
[mips64][clang] Provide the signext attribute for i32 return values

Additional info: see r338019.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338239 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoFix -Wdocumentation warning. NFCI.
Simon Pilgrim [Mon, 30 Jul 2018 10:07:47 +0000 (10:07 +0000)]
Fix -Wdocumentation warning. NFCI.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338238 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[Analyzer] Iterator Checker Hotfix: Defer deletion of container data until its last...
Adam Balogh [Mon, 30 Jul 2018 08:52:21 +0000 (08:52 +0000)]
[Analyzer] Iterator Checker Hotfix: Defer deletion of container data until its last iterator is cleaned up

The analyzer may consider a container region as dead while it still has live
iterators. We must defer deletion of the data belonging to such containers
until all its iterators are dead as well to be able to compare the iterator
to the begin and the end of the container which is stored in the container
data.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338234 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[clang-format] Indent after breaking Javadoc annotated line
Krasimir Georgiev [Mon, 30 Jul 2018 08:45:45 +0000 (08:45 +0000)]
[clang-format] Indent after breaking Javadoc annotated line

Summary:
This patch makes clang-format indent the subsequent lines created by breaking a
long javadoc annotated line.

Reviewers: mprobst

Reviewed By: mprobst

Subscribers: acoomans, cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338232 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoPR38355 Prevent infinite recursion when checking initializer lifetime if
Richard Smith [Mon, 30 Jul 2018 07:19:54 +0000 (07:19 +0000)]
PR38355 Prevent infinite recursion when checking initializer lifetime if
an initializer is self-referential.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338230 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoRevert r337456: [CodeGen] Disable aggressive structor optimizations at -O0, take 3
Chandler Carruth [Sun, 29 Jul 2018 03:05:07 +0000 (03:05 +0000)]
Revert r337456: [CodeGen] Disable aggressive structor optimizations at -O0, take 3

This commit increases the number of sections and overall output size of
.o files by 10% and sometimes a bit more. This alone is challenging for
some users, but it also appears to trigger an as-yet unexplained
behavior in the Gold linker where the memory usage increases
considerably more than 10% (we think).

The increase is also frustrating because in many (if not all) cases we
end up with almost all of the growth coming from the ELF overhead of
-ffunction-sections and such, not from actual extra code being emitted.

Richard Smith and Eric Christopher are both going to investigate this
and try to get to the bottom of what is triggering this and whether the
kinds of increases here are sustainable or what options we might have to
minimize the impact they have. However, this is currently breaking
a pretty large number of our users' builds so reverting it while we sort
out how to make progress here. I've seen a longer and more detailed
update to the commit thread.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338209 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[UBSan] Strengthen pointer checks in 'new' expressions
Serge Pavlov [Sat, 28 Jul 2018 15:33:03 +0000 (15:33 +0000)]
[UBSan] Strengthen pointer checks in 'new' expressions

With this change compiler generates alignment checks for wider range
of types. Previously such checks were generated only for the record types
with non-trivial default constructor. So the types like:

    struct alignas(32) S2 { int x; };
    typedef __attribute__((ext_vector_type(2), aligned(32))) float float32x2_t;

did not get checks when allocated by 'new' expression.

This change also optimizes the checks generated for the arrays created
in 'new' expressions. Previously the check was generated for each
invocation of type constructor. Now the check is generated only once
for entire array.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338199 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[Sema][ObjC] Warn when a method declared in a protocol takes a
Akira Hatanaka [Sat, 28 Jul 2018 04:06:13 +0000 (04:06 +0000)]
[Sema][ObjC] Warn when a method declared in a protocol takes a
non-escaping parameter but the implementation's method takes an escaping
parameter.

rdar://problem/39548196

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338189 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[CUDA][HIP] Allow function-scope static const variable
Yaxun Liu [Sat, 28 Jul 2018 03:05:25 +0000 (03:05 +0000)]
[CUDA][HIP] Allow function-scope static const variable

CUDA 8.0 E.3.9.4 says: Within the body of a __device__ or __global__
function, only __shared__ variables or variables without any device
memory qualifiers may be declared with static storage class.

It is unclear how a function-scope non-const static variable
without device memory qualifier is implemented, therefore only static
const variable without device memory qualifier is allowed, which
can be emitted as a global variable in constant address space.

Currently clang only allows function-scope static variable with
__shared__ qualifier.

This patch also allows function-scope static const variable without
device memory qualifier and emits it as a global variable in constant
address space.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338188 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[AST] Add a convenient getter from QualType to RecordDecl
George Karpenkov [Sat, 28 Jul 2018 02:16:13 +0000 (02:16 +0000)]
[AST] Add a convenient getter from QualType to RecordDecl

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338187 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoCompile SemaTemplate.cpp with /bigobj on MSVC
Erik Pilkington [Sat, 28 Jul 2018 01:29:31 +0000 (01:29 +0000)]
Compile SemaTemplate.cpp with /bigobj on MSVC

This should fix some bot failures introduced by r338165.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338186 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[CFG] Remove duplicate function/class names at the beginning of comments
Fangrui Song [Sat, 28 Jul 2018 00:48:05 +0000 (00:48 +0000)]
[CFG] Remove duplicate function/class names at the beginning of comments

Some functions/classes have renamed while the comments still use the old names. Delete them per coding style.

Also some whitespace cleanup.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338183 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoParse a possible trailing postfix expression suffix after a fold expression
Nicolas Lesser [Fri, 27 Jul 2018 21:55:12 +0000 (21:55 +0000)]
Parse a possible trailing postfix expression suffix after a fold expression

Summary:
This patch allows the parsing of a postfix expression involving a fold expression, which is legal as a fold-expression is a primary-expression.

See also https://llvm.org/pr38282

Reviewers: rsmith

Reviewed By: rsmith

Subscribers: cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338170 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[Sema] Use a TreeTransform to extract deduction guide parameter types
Erik Pilkington [Fri, 27 Jul 2018 21:23:48 +0000 (21:23 +0000)]
[Sema] Use a TreeTransform to extract deduction guide parameter types

Previously, we just canonicalized the type, but this lead to crashes with
parameter types that referred to ParmVarDecls of the constructor. There may be
more cases that this TreeTransform needs to handle though, such as a constructor
parameter type referring to a member in an unevaluated context. Canonicalization
doesn't address these cases either though, so we can address them as-needed in
follow-up commits.

rdar://41330135

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338165 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[DEBUG_INFO] Fix tests, NFC.
Alexey Bataev [Fri, 27 Jul 2018 20:16:44 +0000 (20:16 +0000)]
[DEBUG_INFO] Fix tests, NFC.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338158 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[DEBUGINFO] Disable unsupported debug info options for NVPTX target.
Alexey Bataev [Fri, 27 Jul 2018 19:45:14 +0000 (19:45 +0000)]
[DEBUGINFO] Disable unsupported debug info options for NVPTX target.

Summary:
Some targets support only default set of the debug options and do not
support additional debug options, like NVPTX target. Patch introduced
virtual function supportsDebugInfoOptions() that can be overloaded
by the toolchain, checks if the target supports some debug
options and emits warning when an unsupported debug option is
found.

Reviewers: echristo

Subscribers: aprantl, JDevlieghere, cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338155 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[analyzer] Extend NoStoreFuncVisitor to insert a note on IVars
George Karpenkov [Fri, 27 Jul 2018 18:26:40 +0000 (18:26 +0000)]
[analyzer] Extend NoStoreFuncVisitor to insert a note on IVars

The note is added in the following situation:

 - We are throwing a nullability-related warning on an IVar
 - The path goes through a method which *could have* (syntactically
   determined) written into that IVar, but did not

rdar://42444460

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338149 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoFix typos in comment.
Richard Smith [Fri, 27 Jul 2018 18:06:54 +0000 (18:06 +0000)]
Fix typos in comment.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338141 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[ASTMatchers] Introduce a matcher for `ObjCIvarExpr`, support getting it's declaration
George Karpenkov [Fri, 27 Jul 2018 17:40:59 +0000 (17:40 +0000)]
[ASTMatchers] Introduce a matcher for `ObjCIvarExpr`, support getting it's declaration

ObjCIvarExpr is *not* a subclass of MemberExpr, and a separate matcher
is required to support it.
Adding a hasDeclaration support as well, as it's not very useful without
it.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338140 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[OPENMP] Static variables on device must be externally visible.
Alexey Bataev [Fri, 27 Jul 2018 17:37:32 +0000 (17:37 +0000)]
[OPENMP] Static variables on device must be externally visible.

Do not mark static variable as internal on the device as they must be
visible from the host to be mapped correctly.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338139 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[ASTMatchers] Introduce a matcher for `ObjCIvarExpr`, support getting it's declaration.
George Karpenkov [Fri, 27 Jul 2018 17:26:11 +0000 (17:26 +0000)]
[ASTMatchers] Introduce a matcher for `ObjCIvarExpr`, support getting it's declaration.

ObjCIvarExpr is *not* a subclass of MemberExpr, and a separate matcher
is required to support it.
Adding a hasDeclaration support as well, as it's not very useful without
it.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338137 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoAdd missing temporary materialization conversion on left-hand side of .
Richard Smith [Fri, 27 Jul 2018 17:13:18 +0000 (17:13 +0000)]
Add missing temporary materialization conversion on left-hand side of .
in some member function calls.

Specifically, when calling a conversion function, we would fail to
create the AST node representing materialization of the class object.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338135 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[AST] Sink 'part of explicit cast' down into ImplicitCastExpr
Roman Lebedev [Fri, 27 Jul 2018 07:27:14 +0000 (07:27 +0000)]
[AST] Sink 'part of explicit cast' down into ImplicitCastExpr

Summary:
As discussed in IRC with @rsmith, it is slightly not good to keep that in the `CastExpr` itself:
Given the explicit cast, which is represented in AST as an `ExplicitCastExpr` + `ImplicitCastExpr`'s,
only the  `ImplicitCastExpr`'s will be marked as `PartOfExplicitCast`, but not the `ExplicitCastExpr` itself.
Thus, it is only ever `true` for `ImplicitCastExpr`'s, so we don't need to write/read/dump it for `ExplicitCastExpr`'s.

We don't need to worry that we write the `PartOfExplicitCast` in PCH after `CastExpr::path_iterator`,
since the `ExprImplicitCastAbbrev` is only used when the `NumBaseSpecs == 0`, i.e. there is no 'path'.

Reviewers: rsmith, rjmccall, erichkeane, aaron.ballman

Reviewed By: rsmith, erichkeane

Subscribers: vsk, cfe-commits, rsmith

Tags: #clang

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338108 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[WWW] Fixing file permissions for the .html pages.
Mike Edwards [Fri, 27 Jul 2018 04:41:37 +0000 (04:41 +0000)]
[WWW] Fixing file permissions for the .html pages.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338098 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoadded shared library to fix buildbot
Emmett Neyman [Fri, 27 Jul 2018 00:43:26 +0000 (00:43 +0000)]
added shared library to fix buildbot

Summary: added shared library to fix buildbot

Subscribers: mgorny, cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338091 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[Sema] Fix a crash by completing a type before using it
Erik Pilkington [Thu, 26 Jul 2018 23:40:42 +0000 (23:40 +0000)]
[Sema] Fix a crash by completing a type before using it

Only apply this exception on a type that we're able to check.

rdar://41903969

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338089 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[WWW] Removing my test file as the auto-deployment script has been fixed.
Mike Edwards [Thu, 26 Jul 2018 23:29:54 +0000 (23:29 +0000)]
[WWW] Removing my test file as the auto-deployment script has been fixed.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338087 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[WWW] Adding a test page to work out an auto-deployment issue.
Mike Edwards [Thu, 26 Jul 2018 23:23:40 +0000 (23:23 +0000)]
[WWW] Adding a test page to work out an auto-deployment issue.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338086 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoRevert r338057 "[VirtualFileSystem] InMemoryFileSystem::status: Return a Status with...
Reid Kleckner [Thu, 26 Jul 2018 23:21:51 +0000 (23:21 +0000)]
Revert r338057 "[VirtualFileSystem] InMemoryFileSystem::status: Return a Status with the requested name"

This broke clang/test/PCH/case-insensitive-include.c on Windows.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338084 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[MS] Add L__FUNCSIG__ for compatibility
Reid Kleckner [Thu, 26 Jul 2018 23:18:44 +0000 (23:18 +0000)]
[MS] Add L__FUNCSIG__ for compatibility

Clang already has L__FUNCTION__ as a workaround for dealing with
pre-processor code that expects to be able to do L##__FUNCTION__ in a
macro. This patch implements the same logic for __FUNCSIG__.

Fixes PR38295.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338083 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoUpdated llvm-proto-fuzzer to execute the compiled code
Emmett Neyman [Thu, 26 Jul 2018 22:23:25 +0000 (22:23 +0000)]
Updated llvm-proto-fuzzer to execute the compiled code

Summary:
Made changes to the llvm-proto-fuzzer
- Added loop vectorizer optimization pass in order to have two IR versions
- Updated old fuzz target to handle two different IR versions
- Wrote code to execute both versions in memory

Reviewers: morehouse, kcc, alexshap

Reviewed By: morehouse

Subscribers: pcc, mgorny, cfe-commits, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338077 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[ARM64] [Windows] Follow MS X86_64 C++ ABI when passing structs
Sanjin Sijaric [Thu, 26 Jul 2018 22:18:28 +0000 (22:18 +0000)]
[ARM64] [Windows] Follow MS X86_64 C++ ABI when passing structs

Summary: Microsoft's C++ object model for ARM64 is the same as that for X86_64.
For example, small structs with non-trivial copy constructors or virtual
function tables are passed indirectly.  Currently, they are passed in registers
when compiled with clang.

Reviewers: rnk, mstorsjo, TomTan, haripul, javed.absar

Reviewed By: rnk, mstorsjo

Subscribers: kristof.beyls, chrib, llvm-commits, cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338076 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[VirtualFileSystem] InMemoryFileSystem::status: Return a Status with the requested...
Simon Marchi [Thu, 26 Jul 2018 18:55:02 +0000 (18:55 +0000)]
[VirtualFileSystem] InMemoryFileSystem::status: Return a Status with the requested name

Summary:

InMemoryFileSystem::status behaves differently than
RealFileSystem::status.  The Name contained in the Status returned by
RealFileSystem::status will be the path as requested by the caller,
whereas InMemoryFileSystem::status returns the normalized path.

For example, when requested the status for "../src/first.h",
RealFileSystem returns a Status with "../src/first.h" as the Name.
InMemoryFileSystem returns "/absolute/path/to/src/first.h".

The reason for this change is that I want to make a unit test in the
clangd testsuite (where we use an InMemoryFileSystem) to reproduce a
bug I get with the clangd program (where a RealFileSystem is used).
This difference in behavior "hides" the bug in the unit test version.

Reviewers: malaperle, ilya-biryukov, bkramer

Subscribers: cfe-commits, ioeric, ilya-biryukov, bkramer, hokein, omtcyfz

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338057 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoRefactor checking of switch conditions and case values.
Richard Smith [Thu, 26 Jul 2018 18:41:30 +0000 (18:41 +0000)]
Refactor checking of switch conditions and case values.

Check each case value in turn while parsing it, performing the
conversion to the switch type within the context of the expression
itself. This will become necessary in order to properly handle cleanups
for temporaries created as part of the case label (in an upcoming
patch). For now it's just good hygiene.

This necessitates moving the checking for the switch condition itself to
earlier, so that the destination type is available when checking the
case labels.

As a nice side-effect, we get slightly improved diagnostic quality and
error recovery by separating the case expression checking from the case
statement checking and from tracking whether there are discarded case
labels.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338056 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[OPENMP, DOCS] Fixed typo, NFC.
Alexey Bataev [Thu, 26 Jul 2018 18:40:41 +0000 (18:40 +0000)]
[OPENMP, DOCS] Fixed typo, NFC.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338055 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[COFF, ARM64] Decide when to mark struct returns as SRet
Mandeep Singh Grang [Thu, 26 Jul 2018 18:07:59 +0000 (18:07 +0000)]
[COFF, ARM64] Decide when to mark struct returns as SRet

Summary:
Refer the MS ARM64 ABI Convention for the behavior for struct returns:
https://docs.microsoft.com/en-us/cpp/build/arm64-windows-abi-conventions#return-values

Reviewers: mstorsjo, compnerd, rnk, javed.absar, yinma, efriedma

Reviewed By: rnk, efriedma

Subscribers: haripul, TomTan, yinma, efriedma, kristof.beyls, chrib, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338050 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[OPENMP] What's new for OpenMP in clang.
Alexey Bataev [Thu, 26 Jul 2018 17:53:45 +0000 (17:53 +0000)]
[OPENMP] What's new for OpenMP in clang.

Updated ReleaseNotes + Status of the OpenMP support in clang.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338049 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[Sema][ObjC] Do not propagate the nullability specifier on the receiver
Akira Hatanaka [Thu, 26 Jul 2018 17:51:13 +0000 (17:51 +0000)]
[Sema][ObjC] Do not propagate the nullability specifier on the receiver
to the result type of a message send if the result type cannot have a
nullability specifier.

Previously, clang would print the following message when the code in
nullability.m was compiled:

"incompatible integer to pointer conversion initializing 'int *' with
an expression of type 'int _Nullable'"

This is wrong as 'int' isn't supposed to have any nullability
specifiers.

rdar://problem/40830514

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338048 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago [RISCV] Add support for interrupt attribute
Ana Pazos [Thu, 26 Jul 2018 17:37:45 +0000 (17:37 +0000)]
 [RISCV] Add support for interrupt attribute

Summary:
Clang supports the GNU style ``__attribute__((interrupt))`` attribute  on RISCV targets.
Permissible values for this parameter are user, supervisor, and machine.
If there is no parameter, then it defaults to machine.
Reference: https://gcc.gnu.org/onlinedocs/gcc/RISC-V-Function-Attributes.html
Based on initial patch by Zhaoshi Zheng.

Reviewers: asb, aaron.ballman

Reviewed By: asb, aaron.ballman

Subscribers: rkruppe, the_o, aaron.ballman, MartinMosbeck, brucehoult, rbar, johnrusso, simoncook, sabuasal, niosHD, kito-cheng, shiva0217, zzheng, edward-jones, mgrang, rogfer01, cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338045 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[CodeGen][ObjC] Make block copy/dispose helper functions exception-safe.
Akira Hatanaka [Thu, 26 Jul 2018 16:51:21 +0000 (16:51 +0000)]
[CodeGen][ObjC] Make block copy/dispose helper functions exception-safe.

When an exception is thrown in a block copy helper function, captured
objects that have previously been copied should be destructed or
released. Similarly, captured objects that are yet to be released should
be released when an exception is thrown in a dispose helper function.

rdar://problem/42410255

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338041 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[OPENMP] Force OpenMP 4.5 when compiling for offloading.
Alexey Bataev [Thu, 26 Jul 2018 15:17:38 +0000 (15:17 +0000)]
[OPENMP] Force OpenMP 4.5 when compiling for offloading.

If the user requested compilation for OpenMP with the offloading
support, force the version of the OpenMP standard to 4.5 by default.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338032 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoAllow thread safety annotation lock upgrading and downgrading.
Aaron Ballman [Thu, 26 Jul 2018 13:03:16 +0000 (13:03 +0000)]
Allow thread safety annotation lock upgrading and downgrading.

Patch thanks to Aaron Puchert!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338024 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[ASTMatchers] fix the missing documentation for new decltypeType matcher
Jonas Toth [Thu, 26 Jul 2018 13:02:05 +0000 (13:02 +0000)]
[ASTMatchers] fix the missing documentation for new decltypeType matcher

Summary: Regenerate the Matchers documentation, forgotten in the original patch.

Reviewers: alexfh, aaron.ballman

Reviewed By: aaron.ballman

Subscribers: cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338022 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[analyzer] Fixed method to get APSInt model
Mikhail R. Gadelha [Thu, 26 Jul 2018 11:17:13 +0000 (11:17 +0000)]
[analyzer] Fixed method to get APSInt model

Summary:
This patch replaces the current method of getting an `APSInt` from Z3's model by calling generic API method `getBitvector` instead of `Z3_get_numeral_uint64`.

By calling `getBitvector`, there's no need to handle bitvectors with bit width == 128 separately.

And, as a bonus, clang now compiles correctly with Z3 4.7.1.

Reviewers: NoQ, george.karpenkov

Reviewed By: george.karpenkov

Subscribers: xazax.hun, szepet, a.sidorin

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338020 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[ODRHash] Support hashing enums.
Richard Trieu [Wed, 25 Jul 2018 22:52:05 +0000 (22:52 +0000)]
[ODRHash] Support hashing enums.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@337978 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[OPENMP] ThreadId in serialized parallel regions is 0.
Alexey Bataev [Wed, 25 Jul 2018 20:03:01 +0000 (20:03 +0000)]
[OPENMP] ThreadId in serialized parallel regions is 0.

The first argument for the parallel outlined functions, called as
serialized parallel regions, should be a pointer to the global thread id
that always is 0.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@337957 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[analyzer] Update SMT API documentation and methods
Mikhail R. Gadelha [Wed, 25 Jul 2018 19:34:48 +0000 (19:34 +0000)]
[analyzer] Update SMT API documentation and methods

Summary:
Update the documentation of all the classes introduced with the new generic SMT API, most of them were referencing Z3 and how previous operations were being done (like including the context as parameter in a few methods).

Renamed the following methods, so it's clear that the operate on bitvectors:
*`mkSignExt` -> `mkBVSignExt`
*`mkZeroExt` -> `mkBVZeroExt`
*`mkExtract` -> `mkBVExtract`
*`mkConcat` -> `mkBVConcat`

Removed the unecessary methods:
* `getDataExpr`: it was an one line method that called `fromData`
* `mkBitvector(const llvm::APSInt Int)`: it was not being used anywhere

Reviewers: NoQ, george.karpenkov

Reviewed By: george.karpenkov

Subscribers: xazax.hun, szepet, a.sidorin

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@337954 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[Preprocessor] Stop entering included files after hitting a fatal error.
Volodymyr Sapsai [Wed, 25 Jul 2018 19:16:26 +0000 (19:16 +0000)]
[Preprocessor] Stop entering included files after hitting a fatal error.

Fixes a problem when we have multiple inclusion cycles and try to
enumerate all possible ways to reach the max inclusion depth.

rdar://problem/38871876

Reviewers: bruno, rsmith, jkorous, aaron.ballman

Reviewed By: bruno, jkorous, aaron.ballman

Subscribers: dexonsmith, cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@337953 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[analyzer] Fix compilation when LLVM_ENABLE_MODULES=ON
Mikhail R. Gadelha [Wed, 25 Jul 2018 18:26:50 +0000 (18:26 +0000)]
[analyzer] Fix compilation when LLVM_ENABLE_MODULES=ON

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@337948 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[clang:sema] de-duplicate getDepthAndIndex helpers
Nick Desaulniers [Wed, 25 Jul 2018 18:11:01 +0000 (18:11 +0000)]
[clang:sema] de-duplicate getDepthAndIndex helpers

Summary:
Continuing off of:
https://reviews.llvm.org/D38382

Fixes:
https://bugs.llvm.org/show_bug.cgi?id=12176

Reviewers: srhines, pirama, vsk

Reviewed By: vsk

Subscribers: cfe-commits, vsk, maitesin

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@337944 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[OPENMP] Exclude service expressions/statements from the list of
Alexey Bataev [Wed, 25 Jul 2018 17:27:45 +0000 (17:27 +0000)]
[OPENMP] Exclude service expressions/statements from the list of
the children.

Special internal helper expressions/statements for the OpenMP directives
should not be exposed as children, only the main substatement must be
represented as the child.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@337941 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[OPENMP] Fix PR38256: Fix locations of the artificial conditional op.
Alexey Bataev [Wed, 25 Jul 2018 14:40:26 +0000 (14:40 +0000)]
[OPENMP] Fix PR38256: Fix locations of the artificial conditional op.

Fixed the source locations of the conditional op so that they don'r
crash coverage pass.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@337928 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoFix tsan doc
David Carlier [Wed, 25 Jul 2018 14:27:14 +0000 (14:27 +0000)]
Fix tsan doc

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@337927 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[Docs] Update supported oses for safestack, ubsan, asan, tsan and msan
David Carlier [Wed, 25 Jul 2018 13:55:06 +0000 (13:55 +0000)]
[Docs] Update supported oses for safestack, ubsan, asan, tsan and msan

Adding oses others than Linux.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@337926 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[analyzer] Use the macro REGISTER_TRAIT_WITH_PROGRAMSTATE in the Z3 backend
Mikhail R. Gadelha [Wed, 25 Jul 2018 12:49:47 +0000 (12:49 +0000)]
[analyzer] Use the macro REGISTER_TRAIT_WITH_PROGRAMSTATE in the Z3 backend

Summary:
The macro was manually expanded in the Z3 backend and this patch adds it back.

Adding the expanded code is dangerous as the macro may change in the future and the expanded code might be left outdated.

Reviewers: NoQ, george.karpenkov

Reviewed By: george.karpenkov

Subscribers: xazax.hun, szepet, a.sidorin

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@337923 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[analyzer] Removed API used by the Refutation Manager from SMTConstraintManager and...
Mikhail R. Gadelha [Wed, 25 Jul 2018 12:49:43 +0000 (12:49 +0000)]
[analyzer] Removed API used by the Refutation Manager from SMTConstraintManager and replace by proper calls to SMTSolver

Summary:
Third patch in the refactoring series, to decouple the SMT Solver from the Refutation Manager (1st: D49668, 2nd: D49767).

The refutation API in the `SMTConstraintManager` was a hack to allow us to create an SMT solver and verify the constraints; it was conceptually wrong from the start. Now, we don't actually need to use the `SMTConstraintManager` and can create an SMT object directly, add the constraints and check them.

While updating the Falsification visitor, I inlined the two functions that were used to collect the constraints and add them to the solver.

As a result of this patch, we could move the SMT API elsewhere and as it's not really dependent on the CSA anymore. Maybe we can create a new dir (utils/smt) for Z3 and future solvers?

Reviewers: NoQ, george.karpenkov

Reviewed By: george.karpenkov

Subscribers: xazax.hun, szepet, a.sidorin

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@337922 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[analyzer] Moved code from SMTConstraintManager to SMTSolver
Mikhail R. Gadelha [Wed, 25 Jul 2018 12:49:37 +0000 (12:49 +0000)]
[analyzer] Moved code from SMTConstraintManager to SMTSolver

Summary:
This is the second part of D49668, and moves all the code that's not specific to a ConstraintManager to SMTSolver.

No functional change intended.

Reviewers: NoQ, george.karpenkov

Reviewed By: george.karpenkov

Subscribers: xazax.hun, szepet, a.sidorin

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@337921 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[analyzer] Try to minimize the number of equivalent bug reports evaluated by the...
Mikhail R. Gadelha [Wed, 25 Jul 2018 12:49:32 +0000 (12:49 +0000)]
[analyzer] Try to minimize the number of equivalent bug reports evaluated by the refutation manager

Summary:
This patch changes how the SMT bug refutation runs in an equivalent bug report class.

Now, all other visitor are executed until they find a valid bug or mark all bugs as invalid. When the one valid bug is found (and crosscheck is enabled), the SMT refutation checks the satisfiability of this single bug.

If the bug is still valid after checking with Z3, it is returned and a bug report is created. If the bug is found to be invalid, the next bug report in the equivalent class goes through the same process, until we find a valid bug or all bugs are marked as invalid.

Massive speedups when verifying redis/src/rax.c, from 1500s to 10s.

Reviewers: NoQ, george.karpenkov

Reviewed By: george.karpenkov

Subscribers: xazax.hun, szepet, a.sidorin

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@337920 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[analyzer] Moved non solver specific code from Z3ConstraintManager to SMTConstraintMa...
Mikhail R. Gadelha [Wed, 25 Jul 2018 12:49:29 +0000 (12:49 +0000)]
[analyzer] Moved non solver specific code from Z3ConstraintManager to SMTConstraintManager

Summary:
This patch moves a lot of code from `Z3ConstraintManager` to `SMTConstraintManager`, leaving only the necessary:
* `canReasonAbout` which returns if a Solver can handle a given `SVal` (should be moved to `SMTSolver` in the future).
* `removeDeadBindings`, `assumeExpr` and `print`: methods that need to use `ConstraintZ3Ty`, can probably be moved to `SMTConstraintManager` in the future.

The patch creates a new file, `SMTConstraintManager.cpp` with the moved code. Conceptually, this is move in the right direction and needs further improvements: `SMTConstraintManager` still does a lot of things that are not required by a `ConstraintManager`.

We ought to move the unrelated to `SMTSolver` and remove everything that's not related to a `ConstraintManager`. In particular, we could remove `addRangeConstraints` and `isModelFeasible`, and make the refutation manager create an Z3Solver directly.

Reviewers: NoQ, george.karpenkov

Reviewed By: george.karpenkov

Subscribers: mgorny, xazax.hun, szepet, a.sidorin

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@337919 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[analyzer] Implemented SMT generic API
Mikhail R. Gadelha [Wed, 25 Jul 2018 12:49:23 +0000 (12:49 +0000)]
[analyzer] Implemented SMT generic API

Summary:
Created new SMT generic API.

Small changes to `Z3ConstraintManager` because of the new generic objects (`SMTSort` and `SMTExpr`) returned by `SMTSolver`.

Reviewers: george.karpenkov, NoQ

Reviewed By: george.karpenkov

Subscribers: mgorny, xazax.hun, szepet, a.sidorin

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@337918 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[analyzer] Create generic SMT Expr class
Mikhail R. Gadelha [Wed, 25 Jul 2018 12:49:19 +0000 (12:49 +0000)]
[analyzer] Create generic SMT Expr class

Summary:
New base class for all future SMT Exprs.

No major changes except moving `areEquivalent` and `getFloatSemantics` outside of `Z3Expr` to keep the class minimal.

Reviewers: NoQ, george.karpenkov

Reviewed By: george.karpenkov

Subscribers: xazax.hun, szepet, a.sidorin

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@337917 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[analyzer] Create generic SMT Sort Class
Mikhail R. Gadelha [Wed, 25 Jul 2018 12:49:15 +0000 (12:49 +0000)]
[analyzer] Create generic SMT Sort Class

Summary:
New base class for all future SMT sorts.

The only change is that the class implements methods `isBooleanSort()`, `isBitvectorSort()` and `isFloatSort()` so it doesn't rely on `Z3`'s enum.

Reviewers: NoQ, george.karpenkov

Reviewed By: george.karpenkov

Subscribers: xazax.hun, szepet, a.sidorin

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@337916 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[analyzer] Moved static Context to class member
Mikhail R. Gadelha [Wed, 25 Jul 2018 12:49:11 +0000 (12:49 +0000)]
[analyzer] Moved static Context to class member

Summary:
Although it is a big patch, the changes are simple:
1. There is one `Z3_Context` now, member of the `SMTConstraintManager` class.
2. `Z3Expr`, `Z3Sort`, `Z3Model` and `Z3Solver` are constructed with a reference to the `Z3_Context` in `SMTConstraintManager`.
3. All static functions are now members of `Z3Solver`, e.g, the `SMTConstraintManager` now calls `Solver.fromBoolean(false)` instead of `Z3Expr::fromBoolean(false)`.

Most of the patch only move stuff around except:
1. New method `Z3Sort MkSort(const QualType &Ty, unsigned BitWidth)`, that creates a sort based on the `QualType` and its width. Used to simplify the `fromData` method.

Unfortunate consequence of this patch:
1. `getInterpretation` was moved from `Z3Model` class to `Z3Solver`, because it needs to create a `Z3Sort` before returning the interpretation. This can be fixed by changing both `toAPFloat` and `toAPSInt` by removing the dependency of `Z3Sort` (it's only used to check which Sort was created and to retrieve the type width).

Reviewers: NoQ, george.karpenkov, ddcc

Reviewed By: george.karpenkov

Subscribers: xazax.hun, szepet, a.sidorin

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@337915 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[analyzer] Create generic SMT Context class
Mikhail R. Gadelha [Wed, 25 Jul 2018 12:49:07 +0000 (12:49 +0000)]
[analyzer] Create generic SMT Context class

Summary:
This patch creates `SMTContext` which will wrap a specific SMT context, through `SMTSolverContext`.

The templated `SMTSolverContext` class it's a simple wrapper around a SMT specific context (currently only used in the Z3 backend), while `Z3Context` inherits `SMTSolverContext<Z3_context>` and implements solver specific operations like initialization and destruction of the context.

This separation was done because:

1. We might want to keep one single context, shared across different `SMTConstraintManager`s. It can be achieved by constructing a `SMTContext`, through a function like `CreateSMTContext(Z3)`, `CreateSMTContext(BOOLECTOR)`, etc. The rest of the CSA only need to know about `SMTContext`, so maybe it's a good idea moving `SMTSolverContext` to a separate header in the future.

2. Any generic SMT operation will only require one `SMTSolverContext`object, which can access the specific context by calling `getContext()`.

Reviewers: NoQ, george.karpenkov

Reviewed By: george.karpenkov

Subscribers: xazax.hun, szepet, a.sidorin

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@337914 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[clang-format ]Extend IncludeCategories regex documentation
Krasimir Georgiev [Wed, 25 Jul 2018 10:21:47 +0000 (10:21 +0000)]
[clang-format ]Extend IncludeCategories regex documentation

Summary:
Extend the Clang-Format IncludeCategories documentation by adding a link to the supported regular expression standard (POSIX).
And extenting the example with a system header regex.
[[ https://bugs.llvm.org/show_bug.cgi?id=35041 | bug 35041]]

Contributed by WimLeflere!

Reviewers: krasimir, Typz

Reviewed By: krasimir

Subscribers: cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@337899 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[ASTImporter] Add support for import of CXXInheritedCtorInitExpr.
Balazs Keri [Wed, 25 Jul 2018 10:21:06 +0000 (10:21 +0000)]
[ASTImporter] Add support for import of CXXInheritedCtorInitExpr.

Reviewers: a.sidorin, martong

Reviewed By: martong

Subscribers: rnkovacs, a_sidorin, martong, cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@337898 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agocc1_main: fix -Wsign-compare on FreeBSD
Fangrui Song [Wed, 25 Jul 2018 06:57:31 +0000 (06:57 +0000)]
cc1_main: fix -Wsign-compare on FreeBSD

Its __rlim_t is intentionally signed (__int64_t) because of legacy code
that uses -1 for RLIM_INFINITY.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@337892 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoCodeGen: use non-zero memset when possible for automatic variables
JF Bastien [Wed, 25 Jul 2018 04:29:03 +0000 (04:29 +0000)]
CodeGen: use non-zero memset when possible for automatic variables

Summary:
Right now automatic variables are either initialized with bzero followed by a few stores, or memcpy'd from a synthesized global. We end up encountering a fair amount of code where memcpy of non-zero byte patterns would be better than memcpy from a global because it touches less memory and generates a smaller binary. The optimizer could reason about this, but it's not really worth it when clang already knows.

This code could definitely be more clever but I'm not sure it's worth it. In particular we could track a histogram of bytes seen and figure out (as we do with bzero) if a memset could be followed by a handful of stores. Similarly, we could tune the heuristics for GlobalSize, but using the same as for bzero seems conservatively OK for now.

<rdar://problem/42563091>

Reviewers: dexonsmith

Subscribers: cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@337887 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[profile] Support profiling runtime on Fuchsia
Petr Hosek [Wed, 25 Jul 2018 03:01:35 +0000 (03:01 +0000)]
[profile] Support profiling runtime on Fuchsia

This ports the profiling runtime on Fuchsia and enables the
instrumentation. Unlike on other platforms, Fuchsia doesn't use
files to dump the instrumentation data since on Fuchsia, filesystem
may not be accessible to the instrumented process. We instead use
the data sink to pass the profiling data to the system the same
sanitizer runtimes do.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@337881 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[CMake] Link static libunwind and libc++abi into libc++ in Fuchsia toolchain
Petr Hosek [Wed, 25 Jul 2018 01:44:22 +0000 (01:44 +0000)]
[CMake] Link static libunwind and libc++abi into libc++ in Fuchsia toolchain

When building libc++ for Fuchsia, we want to distribute shared libc++,
libc++abi and libunwind as separate libraries, but for static versions
we would like to link all of them into libc++ so -lc++ flag has the same
effect whether shared or static library is being used.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@337877 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[analyzer] Syntactic matcher for leaks associated with run loop and autoreleasepool
George Karpenkov [Wed, 25 Jul 2018 01:27:15 +0000 (01:27 +0000)]
[analyzer] Syntactic matcher for leaks associated with run loop and autoreleasepool

A checker for detecting leaks resulting from allocating temporary
autoreleasing objects before starting the main run loop.

Checks for two antipatterns:

1. ObjCMessageExpr followed by [[NARunLoop mainRunLoop] run] in the same
autorelease pool.

2. ObjCMessageExpr followed by [[NARunLoop mainRunLoop] run] in no
autorelease pool.

Happens-before relationship is modeled purely syntactically.

rdar://39299145

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@337876 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoRevert "[analyzer] Extend NoStoreFuncVisitor to insert a note on IVars"
George Karpenkov [Tue, 24 Jul 2018 23:23:33 +0000 (23:23 +0000)]
Revert "[analyzer] Extend NoStoreFuncVisitor to insert a note on IVars"

This reverts commit a9e21bd727112cd69eabc1af648c5da6b773d06e.
Reverted because the dependency has not landed yet.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@337866 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[analyzer] Extend NoStoreFuncVisitor to insert a note on IVars
George Karpenkov [Tue, 24 Jul 2018 23:14:29 +0000 (23:14 +0000)]
[analyzer] Extend NoStoreFuncVisitor to insert a note on IVars

The note is added in the following situation:

 - We are throwing a nullability-related warning on an IVar
 - The path goes through a method which *could have* (syntactically
 determined) written into that IVar, but did not

rdar://42444460

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@337864 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[Sema] Destroy tokens in DeclaratorChunk params
Benjamin Kramer [Tue, 24 Jul 2018 22:47:16 +0000 (22:47 +0000)]
[Sema] Destroy tokens in DeclaratorChunk params

Otherwise this leaks in some edge cases.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@337862 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoDon't lifetime-extend or track lifetime problems through the LHS of '->*'.
Richard Smith [Tue, 24 Jul 2018 21:18:30 +0000 (21:18 +0000)]
Don't lifetime-extend or track lifetime problems through the LHS of '->*'.

Fixes a false-positive warning found by selfhost.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@337857 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoRevert "[VFS] Cleanups to VFS interfaces."
Jordan Rupprecht [Tue, 24 Jul 2018 20:28:07 +0000 (20:28 +0000)]
Revert "[VFS] Cleanups to VFS interfaces."

This reverts commit r337834 due to test failures.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@337850 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoRemove stale documentation from InternalsManual.rst
Erich Keane [Tue, 24 Jul 2018 16:11:30 +0000 (16:11 +0000)]
Remove stale documentation from InternalsManual.rst

The DuplicatesAllowedWhileMerging was removed a while ago,
but the documentation remained.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@337835 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[VFS] Cleanups to VFS interfaces.
Sam McCall [Tue, 24 Jul 2018 16:00:55 +0000 (16:00 +0000)]
[VFS] Cleanups to VFS interfaces.

Summary:
- add comments clarifying semantics
- Status::copyWithNewName(Status, Name) --> instance method
- Status::copyWithNewName(fs::file_status, Name) --> constructor (it's not a copy)
- File::getName() -> getRealPath(), reflecting its actual behavior/function
  and stop returning status().getName() in the base class (callers can do this
  fallback if they want to, it complicates the contracts).

This is mostly NFC, but the behavior of File::getName() affects FileManager's
FileEntry::tryGetRealPathName(), which now fails in more cases:
 - non-real file cases
 - real-file cases where the underlying vfs::File was opened in a way that
   doesn't call realpath().
(In these cases we don't know a distinct real name, so in principle it seems OK)

Reviewers: klimek

Subscribers: cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@337834 91177308-0d34-0410-b5e6-96231b3b80d8