]> granicus.if.org Git - clang/log
clang
5 years ago[OPENMP][NVPTX]Mark __kmpc_barrier functions as convergent.
Alexey Bataev [Tue, 4 Dec 2018 15:03:25 +0000 (15:03 +0000)]
[OPENMP][NVPTX]Mark __kmpc_barrier functions as convergent.

__kmpc_barrier runtime functions must be marked as convergent to prevent
some dangerous optimizations. Also, for NVPTX target all barriers must
be emitted as simple barriers.

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

5 years agoRemove reference to recently removed PTH Documentation.
Erich Keane [Tue, 4 Dec 2018 14:46:25 +0000 (14:46 +0000)]
Remove reference to recently removed PTH Documentation.

Removed in r348266

Change-Id: Icff0212f57c42ca84ec174ddd4366ae63a7923fa

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

5 years agoPTH-- Remove feature entirely-
Erich Keane [Tue, 4 Dec 2018 14:34:09 +0000 (14:34 +0000)]
PTH-- Remove feature entirely-

When debugging a boost build with a modified
version of Clang, I discovered that the PTH implementation
stores TokenKind in 8 bits. However, we currently have 368
TokenKinds.

The result is that the value gets truncated and the wrong token
gets picked up when including PTH files. It seems that this will
go wrong every time someone uses a token that uses the 9th bit.

Upon asking on IRC, it was brought up that this was a highly
experimental features that was considered a failure. I discovered
via googling that BoostBuild (mostly Boost.Math) is the only user of
this
feature, using the CC1 flag directly. I believe that this can be
transferred over to normal PCH with minimal effort:
https://github.com/boostorg/build/issues/367

Based on advice on IRC and research showing that this is a nearly
completely unused feature, this patch removes it entirely.

Note: I considered leaving the build-flags in place and making them
emit an error/warning, however since I've basically identified and
warned the only user, it seemed better to just remove them.

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

Change-Id: If32744275ef1f585357bd6c1c813d96973c4d8d9

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

5 years ago[SystemZ] Do not support __float128
Ulrich Weigand [Tue, 4 Dec 2018 10:51:36 +0000 (10:51 +0000)]
[SystemZ] Do not support __float128

As of rev. 268898, clang supports __float128 on SystemZ.  This seems to
have been in error.  GCC has never supported __float128 on SystemZ,
since the "long double" type on the platform is already IEEE-128. (GCC
only supports __float128 on platforms where "long double" is some other
data type.)

For compatibility reasons this patch removes __float128 on SystemZ
again.  The test case is updated accordingly.

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

5 years ago[Analyzer] Iterator Checker - Forbid decrements past the begin() and increments past...
Adam Balogh [Tue, 4 Dec 2018 10:27:27 +0000 (10:27 +0000)]
[Analyzer] Iterator Checker - Forbid decrements past the begin() and increments past the end() of containers

Previously, the iterator range checker only warned upon dereferencing of
iterators outside their valid range as well as increments and decrements of
out-of-range iterators where the result remains out-of-range. However, the C++
standard is more strict than this: decrementing begin() or incrementing end()
results in undefined behaviour even if the iterator is not dereferenced
afterwards. Coming back to the range once out-of-range is also undefined.

This patch corrects the behaviour of the iterator range checker: warnings are
given for any operation whose result is ahead of begin() or past the end()
(which is the past-end iterator itself, thus now we are speaking of past
past-the-end).

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

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

5 years ago[Analyzer] Iterator Checkers - Use the region of the topmost base class for iterators...
Adam Balogh [Tue, 4 Dec 2018 10:22:28 +0000 (10:22 +0000)]
[Analyzer] Iterator Checkers - Use the region of the topmost base class for iterators stored in a region

If an iterator is represented by a derived C++ class but its comparison operator
is for its base the iterator checkers cannot recognize the iterators compared.
This results in false positives in very straightforward cases (range error when
dereferencing an iterator after disclosing that it is equal to the past-the-end
iterator).

To overcome this problem we always use the region of the topmost base class for
iterators stored in a region. A new method called getMostDerivedObjectRegion()
was added to the MemRegion class to get this region.

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

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

5 years agoExtend test for DependentSizedArrayType
Stephen Kelly [Tue, 4 Dec 2018 09:53:36 +0000 (09:53 +0000)]
Extend test for DependentSizedArrayType

Use a using declaration to force the type to appear in the -ast-dump
output.

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

5 years ago[WIP][Sema] Improve static_assert diagnostics for type traits.
Clement Courbet [Tue, 4 Dec 2018 07:59:57 +0000 (07:59 +0000)]
[WIP][Sema] Improve static_assert diagnostics for type traits.

Summary:
In our codebase, `static_assert(std::some_type_trait<Ts...>::value, "msg")`
(where `some_type_trait` is an std type_trait and `Ts...` is the
appropriate template parameters) account for 11.2% of the `static_assert`s.

In these cases, the `Ts` are typically not spelled out explicitly, e.g.
`static_assert(std::is_same<SomeT::TypeT, typename SomeDependentT::value_type>::value, "message");`

The diagnostic when the assert fails is typically not very useful, e.g.
`static_assert failed due to requirement 'std::is_same<SomeT::TypeT, typename SomeDependentT::value_type>::value' "message"`

This change makes the diagnostic spell out the types explicitly , e.g.
`static_assert failed due to requirement 'std::is_same<int, float>::value' "message"`

See tests for more examples.

After this is submitted, I intend to handle
`static_assert(!std::some_type_trait<Ts...>::value, "msg")`,
which is another 6.6% of static_asserts.

Subscribers: cfe-commits

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

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

5 years agoRemove unnecessary include.
Richard Trieu [Tue, 4 Dec 2018 04:53:18 +0000 (04:53 +0000)]
Remove unnecessary include.

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

5 years ago[analyzer] MoveChecker: Add more common state resetting methods.
Artem Dergachev [Tue, 4 Dec 2018 03:38:08 +0000 (03:38 +0000)]
[analyzer] MoveChecker: Add more common state resetting methods.

Includes "resize" and "shrink" because they can reset the object to a known
state in certain circumstances.

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

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

5 years ago[Sema] Provide -fvisibility-global-new-delete-hidden option
Petr Hosek [Tue, 4 Dec 2018 03:25:25 +0000 (03:25 +0000)]
[Sema] Provide -fvisibility-global-new-delete-hidden option

When the global new and delete operators aren't declared, Clang
provides and implicit declaration, but this declaration currently
always uses the default visibility. This is a problem when the
C++ library itself is being built with non-default visibility because
the implicit declaration will force the new and delete operators to
have the default visibility unlike the rest of the library.

The existing workaround is to use assembly to enforce the visiblity:
https://fuchsia.googlesource.com/zircon/+/master/system/ulib/zxcpp/new.cpp#108
but that solution is not always available, e.g. in the case of of
libFuzzer which is using an internal version of libc++ that's also built
with -fvisibility=hidden where the existing behavior is causing issues.

This change introduces a new option -fvisibility-global-new-delete-hidden
which makes the implicit declaration of the global new and delete
operators hidden.

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

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

5 years agoFix -Wmismatched-tags to not warn on redeclarations of structs in system
Richard Smith [Tue, 4 Dec 2018 02:45:28 +0000 (02:45 +0000)]
Fix -Wmismatched-tags to not warn on redeclarations of structs in system
headers.

Previously, we would only check whether the new declaration is in a
system header, but that requires the user to be able to correctly guess
whether a declaration in a system header is declared as a struct or a
class when specializing standard library traits templates.

We now entirely ignore declarations for which the warning was disabled
when determining whether to warn on a tag mismatch.

Also extend the diagnostic message to clarify that
 a) code containing such a tag mismatch is in fact valid and correct,
    and
 b) the (non-coding-style) reason to emit such a warning is that the
    Microsoft C++ ABI is broken and includes the tag kind in decorated
    names,
as it seems a lot of users are confused by our diagnostic here (either
not understanding why we produce it, or believing that it represents an
actual language rule).

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

5 years ago[analyzer] MoveChecker: Improve warning and note messages.
Artem Dergachev [Tue, 4 Dec 2018 02:00:29 +0000 (02:00 +0000)]
[analyzer] MoveChecker: Improve warning and note messages.

The warning piece traditionally describes the bug itself, i.e.
"The bug is a _____", eg. "Attempt to delete released memory",
"Resource leak", "Method call on a moved-from object".

Event pieces produced by the visitor are usually in a present tense, i.e.
"At this moment _____": "Memory is released", "File is closed",
"Object is moved".

Additionally, type information is added into the event pieces for STL objects
(in order to highlight that it is in fact an STL object), and the respective
event piece now mentions that the object is left in an unspecified state
after it was moved, which is a vital piece of information to understand the bug.

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

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

5 years agoNFC: Make this test kinder on downstream forks
Erik Pilkington [Tue, 4 Dec 2018 00:31:31 +0000 (00:31 +0000)]
NFC: Make this test kinder on downstream forks

Downstream forks that have their own attributes often run into this
test failing when a new attribute is added to clang because the
number of supported attributes no longer match. This is redundant
information for this test, so we can get by without it.

rdar://46288577

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

5 years ago[Hexagon] Fix intrinsic test
Krzysztof Parzyszek [Mon, 3 Dec 2018 23:52:33 +0000 (23:52 +0000)]
[Hexagon] Fix intrinsic test

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

5 years agoRelax test even more for Windows
Adrian Prantl [Mon, 3 Dec 2018 23:40:51 +0000 (23:40 +0000)]
Relax test even more for Windows

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

5 years agoRelax tests to also work on Windows
Adrian Prantl [Mon, 3 Dec 2018 23:11:19 +0000 (23:11 +0000)]
Relax tests to also work on Windows

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

5 years ago[analyzer] MoveChecker: Restrict to locals and std:: objects.
Artem Dergachev [Mon, 3 Dec 2018 23:06:07 +0000 (23:06 +0000)]
[analyzer] MoveChecker: Restrict to locals and std:: objects.

In general case there use-after-move is not a bug. It depends on how the
move-constructor or move-assignment is implemented.

In STL, the convention that applies to most classes is that the move-constructor
(-assignment) leaves an object in a "valid but unspecified" state. Using such
object without resetting it to a known state first is likely a bug. Objects

Local value-type variables are special because due to their automatic lifetime
there is no intention to reuse space. If you want a fresh object, you might
as well make a new variable, no need to move from a variable and than re-use it.
Therefore, it is not always a bug, but it is obviously easy to suppress when it
isn't, and in most cases it indeed is - as there's no valid intention behind
the intentional use of a local after move.

This applies not only to local variables but also to parameter variables,
not only of value type but also of rvalue reference type (but not to lvalue
references).

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

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

5 years agoNFC: Add .vscode to .gitignore
Gor Nishanov [Mon, 3 Dec 2018 22:51:07 +0000 (22:51 +0000)]
NFC: Add .vscode to .gitignore

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

5 years ago[analyzer] MoveChecker: NFC: Remove the workaround for the "zombie symbols" bug.
Artem Dergachev [Mon, 3 Dec 2018 22:44:16 +0000 (22:44 +0000)]
[analyzer] MoveChecker: NFC: Remove the workaround for the "zombie symbols" bug.

The checker had extra code to clean up memory regions that were sticking around
in the checker without ever being cleaned up due to the bug that was fixed in
r347953. Because of that, if a region was moved from, then became dead,
and then reincarnated, there were false positives.

Why regions are even allowed to reincarnate is a separate story. Luckily, this
only happens for local regions that don't produce symbols when loaded from.

No functional change intended. The newly added test demonstrates that even
though no cleanup is necessary upon destructor calls, the early return
cannot be removed. It was not failing before the patch.

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

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

5 years ago[analyzer] Rename MisusedMovedObjectChecker to MoveChecker
Artem Dergachev [Mon, 3 Dec 2018 22:32:32 +0000 (22:32 +0000)]
[analyzer] Rename MisusedMovedObjectChecker to MoveChecker

This follows the Static Analyzer's tradition to name checkers after
things in which they find bugs, not after bugs they find.

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

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

5 years ago[analyzer] Dump stable identifiers for objects under construction.
Artem Dergachev [Mon, 3 Dec 2018 22:23:21 +0000 (22:23 +0000)]
[analyzer] Dump stable identifiers for objects under construction.

This continues the work that was started in r342313, which now gets applied to
object-under-construction tracking in C++. Makes it possible to debug
temporaries by dumping exploded graphs again.

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

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

5 years ago[AST] [analyzer] NFC: Reuse code in stable ID dumping methods.
Artem Dergachev [Mon, 3 Dec 2018 22:19:05 +0000 (22:19 +0000)]
[AST] [analyzer] NFC: Reuse code in stable ID dumping methods.

Use the new fancy method introduced in r348197 to simplify some code.

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

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

5 years ago[AST] Generate unique identifiers for CXXCtorInitializer objects.
Artem Dergachev [Mon, 3 Dec 2018 22:15:34 +0000 (22:15 +0000)]
[AST] Generate unique identifiers for CXXCtorInitializer objects.

This continues the work started in r342309 and r342315 to provide identifiers
to AST objects that are shorter and easier to read and remember than pointers.

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

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

5 years agoTypo correction; NFC.
Aaron Ballman [Mon, 3 Dec 2018 21:27:15 +0000 (21:27 +0000)]
Typo correction; NFC.

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

5 years agoNFC: Simplify dumpStmt child handling
Stephen Kelly [Mon, 3 Dec 2018 21:05:52 +0000 (21:05 +0000)]
NFC: Simplify dumpStmt child handling

Reviewers: aaron.ballman

Subscribers: cfe-commits

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

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

5 years agoRe-apply r347954 "[analyzer] Nullability: Don't detect post factum violation..."
Artem Dergachev [Mon, 3 Dec 2018 21:04:30 +0000 (21:04 +0000)]
Re-apply r347954 "[analyzer] Nullability: Don't detect post factum violation..."

Buildbot failures were caused by an unrelated UB that was introduced in r347943
and fixed in r347970.

Also the revision was incorrectly specified as r344580 during revert.

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

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

5 years ago[gcov/Darwin] Ensure external symbols are exported when using an export list
Vedant Kumar [Mon, 3 Dec 2018 20:53:58 +0000 (20:53 +0000)]
[gcov/Darwin] Ensure external symbols are exported when using an export list

Make sure that symbols needed to implement runtime support for gcov are
exported when using an export list on Darwin.

Without the clang driver exporting these symbols, the linker hides them,
resulting in tapi verification failures.

rdar://45944768

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

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

5 years agoPortable Python script across Python version
Serge Guelton [Mon, 3 Dec 2018 20:26:51 +0000 (20:26 +0000)]
Portable Python script across Python version

Workaround naming and hierarchy changes in BaseHTTPServer and SimpleHTTPServer module.

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

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

5 years agoPortable Python script across Python version
Serge Guelton [Mon, 3 Dec 2018 20:12:34 +0000 (20:12 +0000)]
Portable Python script across Python version

Python2 supports both backticks and `repr` to access the __repr__ slot. Python3 only supports `repr`.

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

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

5 years agoAdding tests for -ast-dump; NFC.
Aaron Ballman [Mon, 3 Dec 2018 18:00:31 +0000 (18:00 +0000)]
Adding tests for -ast-dump; NFC.

This adds tests for struct and union declarations in C++.

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

5 years agoAvoid emitting redundant or unusable directories in DIFile metadata entries.
Adrian Prantl [Mon, 3 Dec 2018 17:55:27 +0000 (17:55 +0000)]
Avoid emitting redundant or unusable directories in DIFile metadata entries.

As discussed on llvm-dev recently, Clang currently emits redundant
directories in DIFile entries, such as

  .file      1 "/Volumes/Data/llvm" "/Volumes/Data/llvm/tools/clang/test/CodeGen/debug-info-abspath.c"

This patch looks at any common prefix between the compilation
directory and the (absolute) file path and strips the redundant
part. More importantly it leaves the compilation directory empty if
the two paths have no common prefix.

After this patch the above entry is (assuming a compilation dir of "/Volumes/Data/llvm/_build"):

  .file 1 "/Volumes/Data/llvm" "tools/clang/test/CodeGen/debug-info-abspath.c"

When building the FileCheck binary with debug info, this patch makes
the build artifacts ~1kb smaller.

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

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

5 years ago[Serialization][NFC] Remove pointless "+ 0" in ASTReader
Bruno Ricci [Mon, 3 Dec 2018 16:17:45 +0000 (16:17 +0000)]
[Serialization][NFC] Remove pointless "+ 0" in ASTReader

Remove the pointless "+ 0" which I added for some reason when
modifying these statement/expression classes since it looks
like this is a typo. Following the suggestion of aaron.ballman
in D54902. NFC.

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

5 years ago[AST][Sema] Remove CallExpr::setNumArgs
Bruno Ricci [Mon, 3 Dec 2018 14:54:03 +0000 (14:54 +0000)]
[AST][Sema] Remove CallExpr::setNumArgs

CallExpr::setNumArgs is the only thing that prevents storing the arguments
in a trailing array. There is only 3 places in Sema where setNumArgs is called.
D54900 dealt with one of them.

This patch remove the other two calls to setNumArgs in ConvertArgumentsForCall.
To do this we do the following changes:

1.) Replace the first call to setNumArgs by an assertion since we are moving the
responsability to allocate enough space for the arguments from
Sema::ConvertArgumentsForCall to its callers
(which are Sema::BuildCallToMemberFunction, and Sema::BuildResolvedCallExpr).

2.) Add a new member function CallExpr::shrinkNumArgs, which can only be used
to drop arguments and then replace the second call to setNumArgs by
shrinkNumArgs.

3.) Add a new defaulted parameter MinNumArgs to CallExpr and its derived
classes which specifies a minimum number of argument slots to allocate.
The actual number of arguments slots allocated will be
max(number of args, MinNumArgs) with the extra args nulled. Note that
after the creation of the call expression all of the arguments will be
non-null. It is just during the creation of the call expression that some of
the last arguments can be temporarily null, until filled by default arguments.

4.) Update Sema::BuildCallToMemberFunction by passing the number of parameters
in the function prototype to the constructor of CXXMemberCallExpr. Here the
change is pretty straightforward.

5.) Update Sema::BuildResolvedCallExpr. Here the change is more complicated
since the type-checking for the function type was done after the creation of
the call expression. We need to move this before the creation of the call
expression, and then pass the number of parameters in the function prototype
(if any) to the constructor of the call expression.

6.) Update the deserialization of CallExpr and its derived classes.

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

Reviewed By: aaron.ballman

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

5 years ago[AArch64] Add command-line option for SSBS
Pablo Barrio [Mon, 3 Dec 2018 14:40:37 +0000 (14:40 +0000)]
[AArch64] Add command-line option for SSBS

Summary:
SSBS (Speculative Store Bypass Safe) is only mandatory from 8.5
onwards but is optional from Armv8.0-A. This patch adds testing for
the ssbs command line option, added to allow enabling the feature
in previous Armv8-A architectures to 8.5.

Reviewers: olista01, samparker, aemerson

Reviewed By: samparker

Subscribers: javed.absar, kristof.beyls, cfe-commits

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

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

5 years ago[OpenCL][Sema] Improving formatting
Marco Antognini [Mon, 3 Dec 2018 14:03:49 +0000 (14:03 +0000)]
[OpenCL][Sema] Improving formatting

Reformat comment added in r348120 following
review https://reviews.llvm.org/D55136.

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

5 years ago[CodeComplete] Cleanup access checking in code completion
Ilya Biryukov [Mon, 3 Dec 2018 13:29:17 +0000 (13:29 +0000)]
[CodeComplete] Cleanup access checking in code completion

Summary: Also fixes a crash (see the added 'accessibility-crash.cpp' test).

Reviewers: ioeric, kadircet

Reviewed By: kadircet

Subscribers: cfe-commits

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

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

5 years ago[Sema] Avoid CallExpr::setNumArgs in Sema::BuildCallToObjectOfClassType
Bruno Ricci [Mon, 3 Dec 2018 13:23:56 +0000 (13:23 +0000)]
[Sema] Avoid CallExpr::setNumArgs in Sema::BuildCallToObjectOfClassType

CallExpr::setNumArgs is the only thing that prevents storing the arguments
of a call expression in a trailing array since it might resize the argument
array. setNumArgs is only called in 3 places in Sema, and for all of them it
is possible to avoid it.

This deals with the call to setNumArgs in BuildCallToObjectOfClassType.
Instead of constructing the CXXOperatorCallExpr first and later calling
setNumArgs if we have default arguments, we first construct a large
enough SmallVector, do the promotion/check of the arguments, and
then construct the CXXOperatorCallExpr.

Incidentally this also avoid reallocating the arguments when the
call operator has default arguments but this is not the primary goal.

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

Reviewed By: aaron.ballman

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

5 years ago[AST] Fix an uninitialized bug in the bits of FunctionDecl
Bruno Ricci [Mon, 3 Dec 2018 13:04:10 +0000 (13:04 +0000)]
[AST] Fix an uninitialized bug in the bits of FunctionDecl

FunctionDeclBits.IsCopyDeductionCandidate was not initialized.
This caused a warning with valgrind.

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

5 years agoPortable Python script across Python version
Serge Guelton [Mon, 3 Dec 2018 12:41:35 +0000 (12:41 +0000)]
Portable Python script across Python version

Python3 does not support type destructuring in function parameters.

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

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

5 years ago[AST][NFC] Pack CXXDeleteExpr
Bruno Ricci [Mon, 3 Dec 2018 12:32:32 +0000 (12:32 +0000)]
[AST][NFC] Pack CXXDeleteExpr

Use the newly available space in the bit-fields of Stmt.
This saves 8 bytes per CXXDeleteExpr. NFC.

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

5 years agoPortable Python script across version
Serge Guelton [Mon, 3 Dec 2018 12:12:48 +0000 (12:12 +0000)]
Portable Python script across version

Have all classes derive from object: that's implicitly the default in Python3,
it needs to be done explicilty in Python2.

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

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

5 years agoPortable Python script across Python version
Serge Guelton [Mon, 3 Dec 2018 12:11:21 +0000 (12:11 +0000)]
Portable Python script across Python version

Python2 supports the two following equivalent construct

raise ExceptionType, exception_value
and
raise ExceptionType(exception_value)

Only the later is supported by Python3.

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

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

5 years ago[Analyzer] Actually check for -model-path being a directory
Ilya Biryukov [Mon, 3 Dec 2018 11:34:08 +0000 (11:34 +0000)]
[Analyzer] Actually check for -model-path being a directory

The original patch (r348038) clearly contained a typo and checked
for '-ctu-dir' twice.

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

5 years ago[Analysis] Properly prepare test env in test/Analysis/undef-call.c
Ilya Biryukov [Mon, 3 Dec 2018 11:28:17 +0000 (11:28 +0000)]
[Analysis] Properly prepare test env in test/Analysis/undef-call.c

The test expectes the '%T/ctudir' to be present, but does not create it.

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

5 years ago[clang] Do not read from 'test/SemaCXX/Inputs' inside 'test/AST'
Ilya Biryukov [Mon, 3 Dec 2018 11:26:35 +0000 (11:26 +0000)]
[clang] Do not read from 'test/SemaCXX/Inputs' inside 'test/AST'

Our integrate relies on test inputs being taken from the same diretory as the
test itself.

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

5 years ago[OpenCL][Sema] Improve BuildResolvedCallExpr handling of builtins
Marco Antognini [Mon, 3 Dec 2018 10:58:56 +0000 (10:58 +0000)]
[OpenCL][Sema] Improve BuildResolvedCallExpr handling of builtins

Summary:
This is a follow-up on https://reviews.llvm.org/D52879, addressing a few issues.

This:
 - adds a FIXME for later improvement for specific builtins: I previously have only checked OpenCL ones and ensured tests cover those.
 - fixed the CallExpr type.

Reviewers: riccibruno

Reviewed By: riccibruno

Subscribers: yaxunl, Anastasia, kristina, svenvh, cfe-commits

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

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

5 years ago[CMake] Store path to vendor-specific headers in clang-headers target property
Stefan Granitz [Mon, 3 Dec 2018 10:34:25 +0000 (10:34 +0000)]
[CMake] Store path to vendor-specific headers in clang-headers target property

Summary:
LLDB.framework wants a copy these headers. With this change LLDB can easily glob for the list of files:
```
get_target_property(clang_include_dir clang-headers RUNTIME_OUTPUT_DIRECTORY)
file(GLOB_RECURSE clang_vendor_headers RELATIVE ${clang_include_dir} "${clang_include_dir}/*")
```

By default `RUNTIME_OUTPUT_DIRECTORY` is unset for custom targets like `clang-headers`.

Reviewers: aprantl, JDevlieghere, davide, friss, dexonsmith

Reviewed By: JDevlieghere

Subscribers: mgorny, #lldb, cfe-commits, llvm-commits

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

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

5 years agoReplace FullComment member being visited with parameter
Stephen Kelly [Sun, 2 Dec 2018 17:30:40 +0000 (17:30 +0000)]
Replace FullComment member being visited with parameter

Reviewers: aaron.ballman

Subscribers: cfe-commits

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

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

5 years agoExtend the CommentVisitor with parameter types
Stephen Kelly [Sun, 2 Dec 2018 17:30:34 +0000 (17:30 +0000)]
Extend the CommentVisitor with parameter types

Summary:
This has precedent in the StmtVisitor.  This change will make it
possible to clean up the comment handling in ASTDumper.

Reviewers: aaron.ballman

Subscribers: cfe-commits

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

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

5 years agoRemove unecessary methods
Stephen Kelly [Sun, 2 Dec 2018 17:30:26 +0000 (17:30 +0000)]
Remove unecessary methods

The base class calls VisitExpr

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

5 years agoFix whitespace
Stephen Kelly [Sun, 2 Dec 2018 16:42:34 +0000 (16:42 +0000)]
Fix whitespace

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

5 years agoAdd dump tests for ArrayInitLoopExpr and ArrayInitIndexExpr
Stephen Kelly [Sun, 2 Dec 2018 16:36:23 +0000 (16:36 +0000)]
Add dump tests for ArrayInitLoopExpr and ArrayInitIndexExpr

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

5 years agoOpenCL: Improve vector printf warnings
Matt Arsenault [Sat, 1 Dec 2018 22:16:27 +0000 (22:16 +0000)]
OpenCL: Improve vector printf warnings

The vector modifier is considered separate, so
don't treat it as a conversion specifier.

This is still not warning on some cases, like
using a type that isn't a valid vector element.

Fixes bug 39652

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

5 years agoOpenCL: Extend argument promotion rules to vector types
Matt Arsenault [Sat, 1 Dec 2018 21:56:10 +0000 (21:56 +0000)]
OpenCL: Extend argument promotion rules to vector types

The spec is ambiguous on whether vector types are allowed to be
implicitly converted. The only legal context I think this can
be used for OpenCL is printf, where it seems necessary.

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

5 years agoCorrect indentation.
Bill Wendling [Sat, 1 Dec 2018 09:06:26 +0000 (09:06 +0000)]
Correct indentation.

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

5 years agoSpecify constant context in constant emitter
Bill Wendling [Sat, 1 Dec 2018 08:29:36 +0000 (08:29 +0000)]
Specify constant context in constant emitter

The constant emitter may need to evaluate the expression in a constant context.
For exasmple, global initializer lists.

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

5 years ago[Basic] Move DiagnosticsEngine::dump from .h to .cpp
Fangrui Song [Sat, 1 Dec 2018 01:43:05 +0000 (01:43 +0000)]
[Basic] Move DiagnosticsEngine::dump from .h to .cpp

The two LLVM_DUMP_METHOD methods have a undefined reference on clang::DiagnosticsEngine::DiagStateMap::dump.

tools/clang/tools/extra/clangd/benchmarks/IndexBenchmark links in
clangDaemon but does not link in clangBasic explicitly, which causes a
linker error "undefined symbol" in !NDEBUG + -DBUILD_SHARED_LIBS=on builds.

Move LLVM_DUMP_METHOD methods to .cpp to fix IndexBenchmark. They should
be unconditionally defined as they are also used by non-dump-method #pragma clang __debug diag_mapping

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

5 years agoRelax test to also work on Windows.
Adrian Prantl [Sat, 1 Dec 2018 01:30:00 +0000 (01:30 +0000)]
Relax test to also work on Windows.

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

5 years agoHonor -fdebug-prefix-map when creating function names for the debug info.
Adrian Prantl [Sat, 1 Dec 2018 00:24:27 +0000 (00:24 +0000)]
Honor -fdebug-prefix-map when creating function names for the debug info.

This adds a callback to PrintingPolicy to allow CGDebugInfo to remap
file paths according to -fdebug-prefix-map. Otherwise the debug info
(particularly function names for C++ lambdas) may contain paths that
should have been remapped in the debug info.

<rdar://problem/46128056>

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

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

5 years agoRevert "Revert r347417 "Re-Reinstate 347294 with a fix for the failures.""
Fangrui Song [Fri, 30 Nov 2018 23:41:18 +0000 (23:41 +0000)]
Revert "Revert r347417 "Re-Reinstate 347294 with a fix for the failures.""

It seems the two failing tests can be simply fixed after r348037

Fix 3 cases in Analysis/builtin-functions.cpp
Delete the bad CodeGen/builtin-constant-p.c for now

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

5 years ago[analyzer] Deleting unnecessary test file
Kristof Umann [Fri, 30 Nov 2018 22:32:17 +0000 (22:32 +0000)]
[analyzer] Deleting unnecessary test file

That I really should've done in rC348031.

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

5 years agoAdd myself as code owner for OpenBSD driver
Brad Smith [Fri, 30 Nov 2018 21:42:34 +0000 (21:42 +0000)]
Add myself as code owner for OpenBSD driver

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

5 years agoRevert r347417 "Re-Reinstate 347294 with a fix for the failures."
Fangrui Song [Fri, 30 Nov 2018 21:26:09 +0000 (21:26 +0000)]
Revert r347417 "Re-Reinstate 347294 with a fix for the failures."

Kept the "indirect_builtin_constant_p" test case in test/SemaCXX/constant-expression-cxx1y.cpp
while we are investigating why the following snippet fails:

  extern char extern_var;
  struct { int a; } a = {__builtin_constant_p(extern_var)};

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

5 years ago[analyzer] Emit an error for invalid -analyzer-config inputs
Kristof Umann [Fri, 30 Nov 2018 21:24:31 +0000 (21:24 +0000)]
[analyzer] Emit an error for invalid -analyzer-config inputs

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

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

5 years ago[ExprConstant] Try fixing __builtin_constant_p after D54355 (rC347417)
Fangrui Song [Fri, 30 Nov 2018 21:15:41 +0000 (21:15 +0000)]
[ExprConstant] Try fixing __builtin_constant_p after D54355 (rC347417)

Summary:
Reinstate the original behavior (Success(false, E)) before D54355 when this branch is
taken. This fixes spurious error of the following snippet:

  extern char extern_var;
  struct { int a; } a = {__builtin_constant_p(extern_var)};

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

5 years agoAdding tests for -ast-dump; NFC.
Aaron Ballman [Fri, 30 Nov 2018 20:55:26 +0000 (20:55 +0000)]
Adding tests for -ast-dump; NFC.

This adds tests for struct and union declarations in C. It also points out a bug when dumping anonymous record types -- they are sometimes reported as being contained by something of the wrong tag type. e.g., an anonymous struct inside of a union named X reports the anonymous struct as being inside of 'struct X' rather than 'union X'.

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

5 years agoRevert r348029. I was git-ing and jumped the gun.
Bill Wendling [Fri, 30 Nov 2018 20:44:11 +0000 (20:44 +0000)]
Revert r348029. I was git-ing and jumped the gun.

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

5 years ago[analyzer] Evaluate all non-checker config options before analysis
Kristof Umann [Fri, 30 Nov 2018 20:44:00 +0000 (20:44 +0000)]
[analyzer] Evaluate all non-checker config options before analysis

In earlier patches regarding AnalyzerOptions, a lot of effort went into
gathering all config options, and changing the interface so that potential
misuse can be eliminited.

Up until this point, AnalyzerOptions only evaluated an option when it was
querried. For example, if we had a "-no-false-positives" flag, AnalyzerOptions
would store an Optional field for it that would be None up until somewhere in
the code until the flag's getter function is called.

However, now that we're confident that we've gathered all configs, we can
evaluate off of them before analysis, so we can emit a error on invalid input
even if that prticular flag will not matter in that particular run of the
analyzer. Another very big benefit of this is that debug.ConfigDumper will now
show the value of all configs every single time.

Also, almost all options related class have a similar interface, so uniformity
is also a benefit.

The implementation for errors on invalid input will be commited shorty.

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

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

5 years agoRevert "Reverting r347949-r347951 because they broke the test bots."
George Karpenkov [Fri, 30 Nov 2018 20:43:42 +0000 (20:43 +0000)]
Revert "Reverting r347949-r347951 because they broke the test bots."

This reverts commit 5bad6129c012fbf186eb055be49344e790448ecc.

Hopefully fixing the issue which was breaking the bots.

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

5 years agoWe're in a constant context in the ConstantEmitter.
Bill Wendling [Fri, 30 Nov 2018 20:40:06 +0000 (20:40 +0000)]
We're in a constant context in the ConstantEmitter.

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

5 years agoExpect mixed path separators in FileManagerTest when resolving paths on Win32
Matthew Voss [Fri, 30 Nov 2018 19:52:50 +0000 (19:52 +0000)]
Expect mixed path separators in FileManagerTest when resolving paths on Win32

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

5 years agoRevert an inadvertent change from r348020.
Aaron Ballman [Fri, 30 Nov 2018 19:32:35 +0000 (19:32 +0000)]
Revert an inadvertent change from r348020.

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

5 years ago[analyzer][PlistMacroExpansion] Part 5.: Support for # and ##
Kristof Umann [Fri, 30 Nov 2018 19:21:35 +0000 (19:21 +0000)]
[analyzer][PlistMacroExpansion] Part 5.: Support for # and ##

From what I can see, this should be the last patch needed to replicate macro
argument expansions.

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

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

5 years agoUpdating this test, which changed after the reverts from r348020.
Aaron Ballman [Fri, 30 Nov 2018 19:15:07 +0000 (19:15 +0000)]
Updating this test, which changed after the reverts from r348020.

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

5 years agoReverting r347949-r347951 because they broke the test bots.
Aaron Ballman [Fri, 30 Nov 2018 18:52:51 +0000 (18:52 +0000)]
Reverting r347949-r347951 because they broke the test bots.

http://lab.llvm.org:8011/builders/clang-cmake-armv8-lld/builds/440/steps/ninja%20check%202/logs/FAIL%3A%20Clang%3A%3Aosobject-retain-release.cpp

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

5 years agoMove AST tests into their own test directory; NFC.
Aaron Ballman [Fri, 30 Nov 2018 18:43:02 +0000 (18:43 +0000)]
Move AST tests into their own test directory; NFC.

This moves everything primarily testing the functionality of -ast-dump and -ast-print into their own directory, rather than leaving the tests spread around the testing directory.

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

5 years ago[clang] Fix rL348006 for windows
Kadir Cetinkaya [Fri, 30 Nov 2018 18:36:31 +0000 (18:36 +0000)]
[clang] Fix rL348006 for windows

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

5 years agoAdding tests for -ast-dump; NFC.
Aaron Ballman [Fri, 30 Nov 2018 17:19:06 +0000 (17:19 +0000)]
Adding tests for -ast-dump; NFC.

This adds tests for GenericSelectionExpr; note that it points out a minor whitespace bug for selection expression cases.

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

5 years ago[clang] Fill RealPathName for virtual files.
Kadir Cetinkaya [Fri, 30 Nov 2018 17:10:11 +0000 (17:10 +0000)]
[clang] Fill RealPathName for virtual files.

Summary:
Absolute path information for virtual files were missing even if we
have already stat'd the files. This patch puts that information for virtual
files that can succesffully be stat'd.

Reviewers: ilya-biryukov

Subscribers: cfe-commits

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

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

5 years agoAdding tests for -ast-dump; NFC.
Aaron Ballman [Fri, 30 Nov 2018 15:11:16 +0000 (15:11 +0000)]
Adding tests for -ast-dump; NFC.

This adds tests for DeclStmt and demonstrates that we don't create such an AST node for global declarations currently.

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

5 years agoAdding tests for -ast-dump; NFC.
Aaron Ballman [Fri, 30 Nov 2018 14:43:21 +0000 (14:43 +0000)]
Adding tests for -ast-dump; NFC.

This adds tests for the majority of the functionality around FunctionDecl and CXXMethodDecl.

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

5 years agoFix warning about unused variable [NFC]
Mikael Holmen [Fri, 30 Nov 2018 13:38:33 +0000 (13:38 +0000)]
Fix warning about unused variable [NFC]

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

5 years agolyzer] [HOTFIX!] SValBuilder crash when `aggressive-binary-operation-simplification...
Adam Balogh [Fri, 30 Nov 2018 10:37:44 +0000 (10:37 +0000)]
lyzer] [HOTFIX!] SValBuilder crash when `aggressive-binary-operation-simplification` enabled

During the review of D41938 a condition check with an early exit accidentally
slipped into a branch, leaving the other branch unprotected. This may result in
an assertion later on. This hotfix moves this contition check outside of the
branch.

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

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

5 years agoFix a use-after-scope bug.
Haojian Wu [Fri, 30 Nov 2018 09:23:01 +0000 (09:23 +0000)]
Fix a use-after-scope bug.

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

5 years agoRevert r344580 "[analyzer] Nullability: Don't detect post factum violation..."
Artem Dergachev [Fri, 30 Nov 2018 04:26:17 +0000 (04:26 +0000)]
Revert r344580 "[analyzer] Nullability: Don't detect post factum violation..."

Fails under ASan!

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

5 years ago[analyzer] MallocChecker: Avoid redundant transitions.
Artem Dergachev [Fri, 30 Nov 2018 03:52:42 +0000 (03:52 +0000)]
[analyzer] MallocChecker: Avoid redundant transitions.

Don't generate a checker-tagged node unconditionally on the first
checkDeadSymbols callback when no pointers are tracked.

This is a tiny performance optimization; it may change the behavior slightly
by making Static Analyzer bail out on max-nodes one node later (which is good)
but any test would either break for no good reason or become useless
every time someone sneezes.

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

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

5 years ago[analyzer] Nullability: Don't detect post factum violation on concrete values.
Artem Dergachev [Fri, 30 Nov 2018 03:39:58 +0000 (03:39 +0000)]
[analyzer] Nullability: Don't detect post factum violation on concrete values.

The checker suppresses warnings on paths on which a nonnull value is assumed
to be nullable. This probably deserves a warning, but it's a separate story.

Now, because dead symbol collection fires in pretty random moments,
there sometimes was a situation when dead symbol collection fired after
computing a parameter but before actually evaluating call enter into the
function, which triggered the suppression when the argument was null
in the first place earlier than the obvious warning for null-to-nonnull
was emitted, causing false negatives.

Only trigger the suppression for symbols, not for concrete values.

It is impossible to constrain a concrete value post-factum because
it is impossible to constrain a concrete value at all.

This covers all the necessary cases because by the time we reach the call,
symbolic values should be either not constrained to null, or already collapsed
into concrete null values. Which in turn happens because they are passed through
the Store, and the respective collapse is implemented as part of getSVal(),
which is also weird.

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

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

5 years ago[analyzer] Fix the "Zombie Symbols" bug.
Artem Dergachev [Fri, 30 Nov 2018 03:27:50 +0000 (03:27 +0000)]
[analyzer] Fix the "Zombie Symbols" bug.

It's an old bug that consists in stale references to symbols remaining in the
GDM if they disappear from other program state sections as a result of any
operation that isn't the actual dead symbol collection. The most common example
here is:

   FILE *fp = fopen("myfile.txt", "w");
   fp = 0; // leak of file descriptor

In this example the leak were not detected previously because the symbol
disappears from the public part of the program state due to evaluating
the assignment. For that reason the checker never receives a notification
that the symbol is dead, and never reports a leak.

This patch not only causes leak false negatives, but also a number of other
problems, including false positives on some checkers.

What's worse, even though the program state contains a finite number of symbols,
the set of symbols that dies is potentially infinite. This means that is
impossible to compute the set of all dead symbols to pass off to the checkers
for cleaning up their part of the GDM.

No longer compute the dead set at all. Disallow iterating over dead symbols.
Disallow querying if any symbols are dead. Remove the API for marking symbols
as dead, as it is no longer necessary. Update checkers accordingly.

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

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

5 years ago[analyzer] Fixes after rebase.
George Karpenkov [Fri, 30 Nov 2018 02:19:29 +0000 (02:19 +0000)]
[analyzer] Fixes after rebase.

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

5 years ago[analyzer] RetainCountChecker for OSObject model the "free" call
George Karpenkov [Fri, 30 Nov 2018 02:19:16 +0000 (02:19 +0000)]
[analyzer] RetainCountChecker for OSObject model the "free" call

The "free" call frees the object immediately, ignoring the reference count.
Sadly, it is actually used in a few places, so we need to model it.

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

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

5 years ago[analyzer] RetainCountChecker: recognize that OSObject can be created directly using...
George Karpenkov [Fri, 30 Nov 2018 02:19:03 +0000 (02:19 +0000)]
[analyzer] RetainCountChecker: recognize that OSObject can be created directly using an operator "new"

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

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

5 years ago[analyzer] Switch retain count checker for OSObject to use OS_* attributes
George Karpenkov [Fri, 30 Nov 2018 02:18:50 +0000 (02:18 +0000)]
[analyzer] Switch retain count checker for OSObject to use OS_* attributes

Instead of generalized reference counting annotations.

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

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

5 years ago[attributes] Add a family of OS_CONSUMED, OS_RETURNS and OS_RETURNS_RETAINED attributes
George Karpenkov [Fri, 30 Nov 2018 02:18:37 +0000 (02:18 +0000)]
[attributes] Add a family of OS_CONSUMED, OS_RETURNS and OS_RETURNS_RETAINED attributes

The addition adds three attributes for communicating ownership,
analogous to existing NS_ and CF_ attributes.
The attributes are meant to be used for communicating ownership of all
objects in XNU (Darwin kernel) and all of the kernel modules.
The ownership model there is very similar, but still different from the
Foundation model, so we think that introducing a new family of
attributes is appropriate.

The addition required a sizeable refactoring of the existing code for
CF_ and NS_ ownership attributes, due to tight coupling and the fact
that differentiating between the types was previously done using a
boolean.

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

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

5 years ago[analyzer] [NFC] Minor refactoring of RetainCountDiagnostics
George Karpenkov [Fri, 30 Nov 2018 02:18:23 +0000 (02:18 +0000)]
[analyzer] [NFC] Minor refactoring of RetainCountDiagnostics

Move visitors to the implementation file, move a complicated logic into
a function.

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

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

5 years ago[analyzer] For OSObject, trust that functions starting with Get
George Karpenkov [Fri, 30 Nov 2018 02:18:10 +0000 (02:18 +0000)]
[analyzer] For OSObject, trust that functions starting with Get

(uppercase) are also getters.

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

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

5 years ago[analyzer] Print a fully qualified name for functions in RetainCountChecker diagnostics
George Karpenkov [Fri, 30 Nov 2018 02:17:57 +0000 (02:17 +0000)]
[analyzer] Print a fully qualified name for functions in RetainCountChecker diagnostics

Attempt to get a fully qualified name from AST if an SVal corresponding
to the object is not available.

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

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

5 years ago[analyzer] Add the type of the leaked object to the diagnostic message
George Karpenkov [Fri, 30 Nov 2018 02:17:44 +0000 (02:17 +0000)]
[analyzer] Add the type of the leaked object to the diagnostic message

If the object is a temporary, and there is no variable it binds to,
let's at least print out the object name in order to help differentiate
it from other temporaries.

rdar://45175098

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

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

5 years ago[analyzer] Reference leaked object by name, even if it was created in an inlined...
George Karpenkov [Fri, 30 Nov 2018 02:17:31 +0000 (02:17 +0000)]
[analyzer] Reference leaked object by name, even if it was created in an inlined function.

rdar://45532181

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

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

5 years ago[analyzer] [NFC] Test dumping trimmed graph
George Karpenkov [Fri, 30 Nov 2018 02:17:18 +0000 (02:17 +0000)]
[analyzer] [NFC] Test dumping trimmed graph

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

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