]> granicus.if.org Git - clang/log
clang
6 years ago[analyzer] added cache for SMT queries in the SMTConstraintManager
Mikhail R. Gadelha [Thu, 23 Aug 2018 13:21:35 +0000 (13:21 +0000)]
[analyzer] added cache for SMT queries in the SMTConstraintManager

Summary:
This patch implements a new cache for the result of SMT queries; with this patch the regression tests are 25% faster.

It's implemented as a `llvm::DenseMap` where the key is the hash of the set of the constraints in a state.

There is still one method that does not use the cache, `getSymVal`, because it needs to get a symbol interpretation from the SMT, which is not cached yet.

Reviewers: NoQ, george.karpenkov

Reviewed By: george.karpenkov

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

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

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

6 years ago[analyzer] Moved all CSA code from the SMT API to a new header, `SMTConv.h`. NFC.
Mikhail R. Gadelha [Thu, 23 Aug 2018 13:21:31 +0000 (13:21 +0000)]
[analyzer] Moved all CSA code from the SMT API to a new header, `SMTConv.h`. NFC.

Summary:
With this patch, the SMT backend is almost completely detached from the CSA.

Unfortunate consequence is that we missed the `ConditionTruthVal` from the CSA and had to use `Optional<bool>`.

The Z3 solver implementation is still in the same file as the `Z3ConstraintManager`, in `lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp` though, but except for that, the SMT API can be moved to anywhere in the codebase.

Reviewers: NoQ, george.karpenkov

Reviewed By: george.karpenkov

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

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

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

6 years ago[analyzer] Templatefy SMTConstraintManager so more generic code can be moved from...
Mikhail R. Gadelha [Thu, 23 Aug 2018 13:21:00 +0000 (13:21 +0000)]
[analyzer] Templatefy SMTConstraintManager so more generic code can be moved from solver specific implementations. NFC.

Summary:
By making SMTConstraintManager a template and passing the SMT constraint type and expr, we can further move code from the Z3ConstraintManager class to the generic SMT constraint Manager.

Now, each SMT specific constraint manager only needs to implement the method `bool canReasonAbout(SVal X) const`.

Reviewers: NoQ, george.karpenkov

Reviewed By: george.karpenkov

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

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

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

6 years ago[analyzer] Delete SMTContext. NFC.
Mikhail R. Gadelha [Thu, 23 Aug 2018 13:20:18 +0000 (13:20 +0000)]
[analyzer] Delete SMTContext. NFC.

Summary: There is no reason to have a base class for a context anymore as each SMT object carries a reference to the specific solver context.

Reviewers: NoQ, george.karpenkov, hiraditya

Reviewed By: hiraditya

Subscribers: hiraditya, xazax.hun, szepet, a.sidorin, Szelethus

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

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

6 years agoChange dyn_cast<CXXMethodDecl>(FD) to isa<CXXMethodDecl>(FD) [NFC]
Mikael Holmen [Thu, 23 Aug 2018 13:18:27 +0000 (13:18 +0000)]
Change dyn_cast<CXXMethodDecl>(FD) to isa<CXXMethodDecl>(FD) [NFC]

The result of the dyn_cast wasn't used to we can just check isa.

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

6 years agoRemoved unused variable [NFC]
Mikael Holmen [Thu, 23 Aug 2018 10:59:49 +0000 (10:59 +0000)]
Removed unused variable [NFC]

The compiler warned:
../tools/clang/lib/StaticAnalyzer/Core/RetainSummaryManager.cpp:329:19: error: unused variable 'MD' [-Werror,-Wunused-variable]
  if (const auto *MD = dyn_cast<CXXMethodDecl>(FD)) {
                  ^
1 error generated.

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

6 years agoUpdate avr attributes test for output change in r340519
Alexander Richardson [Thu, 23 Aug 2018 10:21:36 +0000 (10:21 +0000)]
Update avr attributes test for output change in r340519

After this commit there is an addrspace(1) before the attribute #. Since
these tests are only checking the value of the attribute add a {{.*}} to
make the test resilient to future output changes.

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

6 years ago[libclang] Fix cursors for arguments of Subscript and Call operators
Ivan Donchevskii [Thu, 23 Aug 2018 09:48:11 +0000 (09:48 +0000)]
[libclang] Fix cursors for arguments of Subscript and Call operators

The DeclRefExpr of CXXOperatorCallExpr refering to the custom operator
is visited before the arguments to the operator call. For the Call and
Subscript operator the range of this DeclRefExpr includes the whole call
expression, so that all tokens in that range were mapped to the operator
function, even the tokens of the arguments.

Fix this by ensuring that this particular DeclRefExpr is visited last.

Fixes PR25775.

Fix by Nikolai Kosjar.

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

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

6 years ago[x86/retpoline] Split the LLVM concept of retpolines into separate
Chandler Carruth [Thu, 23 Aug 2018 06:06:38 +0000 (06:06 +0000)]
[x86/retpoline] Split the LLVM concept of retpolines into separate
subtarget features for indirect calls and indirect branches.

This is in preparation for enabling *only* the call retpolines when
using speculative load hardening.

I've continued to use subtarget features for now as they continue to
seem the best fit given the lack of other retpoline like constructs so
far.

The LLVM side is pretty simple. I'd like to eventually get rid of the
old feature, but not sure what backwards compatibility issues that will
cause.

This does remove the "implies" from requesting an external thunk. This
always seemed somewhat questionable and is now clearly not desirable --
you specify a thunk the same way no matter which set of things are
getting retpolines.

I really want to keep this nicely isolated from end users and just an
LLVM implementation detail, so I've moved the `-mretpoline` flag in
Clang to no longer rely on a specific subtarget feature by that name and
instead to be directly handled. In some ways this is simpler, but in
order to preserve existing behavior I've had to add some fallback code
so that users who relied on merely passing -mretpoline-external-thunk
continue to get the same behavior. We should eventually remove this
I suspect (we have never tested that it works!) but I've not done that
in this patch.

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

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

6 years agoMissing quote in previous commit
JF Bastien [Thu, 23 Aug 2018 04:09:49 +0000 (04:09 +0000)]
Missing quote in previous commit

The test was failing because I missed a quote.

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

6 years agoImprove incompatible triple error
JF Bastien [Thu, 23 Aug 2018 03:55:24 +0000 (03:55 +0000)]
Improve incompatible triple error

When complaining that the triple is incompatible with all targets, print out the triple not just a generic error about triples not matching.

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

6 years ago[analyzer] Preliminary version of retain count checking for OSObjects
George Karpenkov [Thu, 23 Aug 2018 00:26:59 +0000 (00:26 +0000)]
[analyzer] Preliminary version of retain count checking for OSObjects

Has quite a lot of false positives, disabled behind the flag.

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

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

6 years agoRevert "[CStringSyntaxChecker] Check strlcat sizeof check"
George Karpenkov [Thu, 23 Aug 2018 00:02:35 +0000 (00:02 +0000)]
Revert "[CStringSyntaxChecker] Check strlcat sizeof check"

This reverts commit 3073790e87378fea9a68fb052185fec9596ef135.

The check is not correct, strlact(dest, "mystr", sizeof(dest)) is fine.

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

6 years agoRevert "[CStringSyntaxChecker] Reduces space around error message for strlcat."
George Karpenkov [Thu, 23 Aug 2018 00:02:12 +0000 (00:02 +0000)]
Revert "[CStringSyntaxChecker] Reduces space around error message for strlcat."

This reverts commit 6b43b80320722da41ca6ef7a3b57cc300fb83094.

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

6 years agowin: Omit ".exe" from clang and clang-cl driver-level diagnostics.
Nico Weber [Wed, 22 Aug 2018 23:53:39 +0000 (23:53 +0000)]
win: Omit ".exe" from clang and clang-cl driver-level diagnostics.

Like https://reviews.llvm.org/D51133 but for clang.
https://reviews.llvm.org/D51134

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

6 years agoRevert "[ASTImporter] Add test for ObjCAtTryStmt/ObjCAtCatchStmt/ObjCAtThrowStmt"
Raphael Isemann [Wed, 22 Aug 2018 23:50:30 +0000 (23:50 +0000)]
Revert "[ASTImporter] Add test for ObjCAtTryStmt/ObjCAtCatchStmt/ObjCAtThrowStmt"

This test breaks llvm-clang-x86_64-expensive-checks-win.

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

6 years ago[NFC] Add tags file to .gitignore
George Karpenkov [Wed, 22 Aug 2018 23:23:17 +0000 (23:23 +0000)]
[NFC] Add tags file to .gitignore

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

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

6 years ago[analyzer] Track non-zero values in ReturnVisitor
George Karpenkov [Wed, 22 Aug 2018 23:17:25 +0000 (23:17 +0000)]
[analyzer] Track non-zero values in ReturnVisitor

Tracking those can help to provide much better diagnostics in many cases.

In general, most of the visitor machinery should be refactored to allow
tracking the origin of arbitrary values.

rdar://36039765

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

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

6 years ago[analyzer] Track the problematic subexpression in UndefResultChecker
George Karpenkov [Wed, 22 Aug 2018 23:17:02 +0000 (23:17 +0000)]
[analyzer] Track the problematic subexpression in UndefResultChecker

This is tested in a subsequent commit, which allows tracking those values.

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

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

6 years ago[analyzer] [NFC] Minor refactoring of BugReporterVisitors
George Karpenkov [Wed, 22 Aug 2018 23:16:44 +0000 (23:16 +0000)]
[analyzer] [NFC] Minor refactoring of BugReporterVisitors

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

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

6 years ago[Driver] Check normalized triples for multiarch runtime path
Petr Hosek [Wed, 22 Aug 2018 22:56:46 +0000 (22:56 +0000)]
[Driver] Check normalized triples for multiarch runtime path

Previously we only used target triple as provided which matches the
GCC behavior, but it also means that all clients have to be consistent
in their spelling of target triples since e.g. x86_64-linux-gnu and
x86_64-unknown-linux-gnu will result in Clang driver looking at two
different paths when searching for runtime libraries.

Unfortunatelly, as it turned out many clients aren't consistent in
their spelling of target triples, e.g. many Linux distributions use
the shorter spelling but config.guess and rustc insist on using the
normalized variant which is causing issues. To avoid having to ship
multiple copies of runtimes for different triple spelling or rely on
symlinks which are not portable, we should also check the normalized
triple when constructing paths for multiarch runtimes.

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

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

6 years ago[ASTImporter] Add test for ObjCAtTryStmt/ObjCAtCatchStmt/ObjCAtThrowStmt
Raphael Isemann [Wed, 22 Aug 2018 22:51:37 +0000 (22:51 +0000)]
[ASTImporter] Add test for ObjCAtTryStmt/ObjCAtCatchStmt/ObjCAtThrowStmt

Reviewers: a.sidorin, a_sidorin

Reviewed By: a_sidorin

Subscribers: martong, cfe-commits

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

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

6 years ago[ASTImporter] Actually test ArrayInitLoopExpr in the array-init-loop-expr test.
Raphael Isemann [Wed, 22 Aug 2018 22:50:45 +0000 (22:50 +0000)]
[ASTImporter] Actually test ArrayInitLoopExpr in the array-init-loop-expr test.

Summary:
The `array-init-loop-expr` test is currently not testing the importing of ArrayInitLoopExprs.

This is because we import the `S` struct into the `test.cpp` context
and only do a copy-assignment in `test.cpp`, so the actual ArrayInitLoopExpr we wanted to
import is generated by clang directly in the target context. This means we actually
never test the importing of ArrayInitLoopExpr with this test, which becomes obvious
when looking at the missing test coverage for the respective  VisitArrayInitLoopExpr method.

This patch moves the copy-assignment of our struct to the `S.cpp` context, which means
that `test.cpp` now actually has to import the ArrayInitLoopExpr.

Reviewers: a.sidorin, a_sidorin

Reviewed By: a_sidorin

Subscribers: a_sidorin, martong, cfe-commits

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

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

6 years ago[ASTImporter] Remove duplicated and dead CXXNamedCastExpr handling code.
Raphael Isemann [Wed, 22 Aug 2018 22:49:32 +0000 (22:49 +0000)]
[ASTImporter] Remove duplicated and dead CXXNamedCastExpr handling code.

Summary:
`CXXNamedCastExpr` importing is already handled in the respective `VisitCXXNamedCastExpr` method.
So this code here can never be reached under normal circumstances and we might as well remove it.

This patch shouldn't change any observable behavior of the ASTImporter.

Reviewers: a.sidorin, a_sidorin

Reviewed By: a_sidorin

Subscribers: martong, cfe-commits

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

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

6 years ago[ASTImporter] Add test for ObjCTypeParamDecl
Raphael Isemann [Wed, 22 Aug 2018 22:48:40 +0000 (22:48 +0000)]
[ASTImporter] Add test for ObjCTypeParamDecl

Reviewers: a.sidorin, a_sidorin

Reviewed By: a_sidorin

Subscribers: martong, cfe-commits

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

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

6 years ago[ASTImporter] Add test for SwitchStmt
Raphael Isemann [Wed, 22 Aug 2018 22:47:10 +0000 (22:47 +0000)]
[ASTImporter] Add test for SwitchStmt

Reviewers: a.sidorin, a_sidorin

Reviewed By: a_sidorin

Subscribers: a_sidorin, martong, cfe-commits

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

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

6 years ago[ASTImporter] Add test for ObjCAutoreleasePoolStmt
Raphael Isemann [Wed, 22 Aug 2018 22:45:04 +0000 (22:45 +0000)]
[ASTImporter] Add test for ObjCAutoreleasePoolStmt

Reviewers: a.sidorin, a_sidorin

Reviewed By: a_sidorin

Subscribers: martong, cfe-commits

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

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

6 years agoThread safety analysis: Allow relockable scopes
Aaron Puchert [Wed, 22 Aug 2018 22:14:53 +0000 (22:14 +0000)]
Thread safety analysis: Allow relockable scopes

Summary:
It's already allowed to prematurely release a scoped lock, now we also
allow relocking it again, possibly even in another mode.

This is the second attempt, the first had been merged as r339456 and
reverted in r339558 because it caused a crash.

Reviewers: delesley, aaron.ballman

Reviewed By: delesley, aaron.ballman

Subscribers: hokein, cfe-commits

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

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

6 years ago[NFC] Test commit
Aaron Puchert [Wed, 22 Aug 2018 21:06:04 +0000 (21:06 +0000)]
[NFC] Test commit

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

6 years agoCurrently clang does not emit unused static constants. GCC emits these
Elizabeth Andrews [Wed, 22 Aug 2018 19:05:19 +0000 (19:05 +0000)]
Currently clang does not emit unused static constants. GCC emits these
constants by default when there is no optimization.

GCC's option -fno-keep-static-consts can be used to not emit
unused static constants.

In Clang, since default behavior does not keep unused static constants,
-fkeep-static-consts can be used to emit these if required. This could be
useful for producing identification strings like SVN identifiers
inside the object file even though the string isn't used by the program.

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

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

6 years ago[Android] Default to -fno-math-errno
Pirama Arumuga Nainar [Wed, 22 Aug 2018 17:43:05 +0000 (17:43 +0000)]
[Android] Default to -fno-math-errno

Summary: Android's libm does not set errno.

Reviewers: srhines, enh

Subscribers: cfe-commits

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

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

6 years ago[Tooling] Allow -flto flags and filter out -Wa, flags
Chih-Hung Hsieh [Wed, 22 Aug 2018 17:13:40 +0000 (17:13 +0000)]
[Tooling] Allow -flto flags and filter out -Wa, flags

This change fixes the problem in https://bugs.llvm.org/show_bug.cgi?id=38332
by allowing driver::Action::BackendJobClass to run with the analyzer.
Otherwise, such jobs will look up the non-existing compilation database
and then run without flags.
Also filter out the -Wa,* flags that could be passed to and ignored
by the clang compiler.  Clang-tidy gives warnings about unused -Wa,* flags.

Differential Revision: http://reviews.llvm.org/D51002

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

6 years ago[CodeGen] Look at the type of a block capture field rather than the type
Akira Hatanaka [Wed, 22 Aug 2018 13:41:19 +0000 (13:41 +0000)]
[CodeGen] Look at the type of a block capture field rather than the type
of the captured variable when determining whether the capture needs
special handing when the block is copied or disposed.

This fixes bugs in the handling of variables captured by a block that is
nested inside a lambda that captures the variables by reference.

rdar://problem/43540889

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

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

6 years ago[analyzer] Improve `CallDescription` to handle c++ method.
Henry Wong [Wed, 22 Aug 2018 13:30:46 +0000 (13:30 +0000)]
[analyzer] Improve `CallDescription` to handle c++ method.

Summary:
`CallDecription` can only handle function for the time being. If we want to match c++ method, we can only use method name to match and can't improve the matching accuracy through the qualifiers.

This patch add the support for `QualifiedName` matching to improve the matching accuracy.

Reviewers: xazax.hun, NoQ, george.karpenkov, rnkovacs

Reviewed By: xazax.hun, NoQ, rnkovacs

Subscribers: Szelethus, szepet, rnkovacs, a.sidorin, mikhail.ramalho, cfe-commits, MTC

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

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

6 years ago[Preamble] Fix an undefined behavior when checking an empty preamble can be reused.
Haojian Wu [Wed, 22 Aug 2018 12:34:04 +0000 (12:34 +0000)]
[Preamble] Fix an undefined behavior when checking an empty preamble can be reused.

Summary: Passing nullptr to memcmp is UB.

Reviewers: ilya-biryukov

Reviewed By: ilya-biryukov

Subscribers: cfe-commits

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

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

6 years agoFix import of class templates partial specialization
Gabor Marton [Wed, 22 Aug 2018 11:52:14 +0000 (11:52 +0000)]
Fix import of class templates partial specialization

Summary:
Currently there are several issues with the import of class template
specializations.  (1) Different TUs may have class template specializations
with the same template arguments, but with different set of instantiated
MethodDecls and FieldDecls.  In this patch we provide a fix to merge these
methods and fields.  (2) Currently, we search the partial template
specializations in the set of simple specializations and we add partial
specializations as simple specializations. This is bad, this patch fixes it.

Reviewers: a_sidorin, xazax.hun, r.stahl

Subscribers: rnkovacs, dkrupp, cfe-commits

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

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

6 years ago[AArch64] Add Tiny Code Model for AArch64
David Green [Wed, 22 Aug 2018 11:34:28 +0000 (11:34 +0000)]
[AArch64] Add Tiny Code Model for AArch64

Adds a tiny code model to Clang along side rL340397.

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

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

6 years agoFix Wdocumentation warnings. NFCI.
Simon Pilgrim [Wed, 22 Aug 2018 10:08:53 +0000 (10:08 +0000)]
Fix Wdocumentation warnings. NFCI.

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

6 years ago[clang][mips] Set __mips_fpr correctly for -mfpxx
Stefan Maksimovic [Wed, 22 Aug 2018 09:26:25 +0000 (09:26 +0000)]
[clang][mips] Set __mips_fpr correctly for -mfpxx

Set __mips_fpr to 0 if o32 ABI is used with either -mfpxx
or none of -mfp32, -mfpxx, -mfp64 being specified.

Introduce additional checks:
-mfpxx is only to be used in conjunction with the o32 ABI.
report an error when incompatible options are provided.

Formerly no errors were raised when combining n32/n64 ABIs
with -mfp32 and -mfpxx.

There are other cases when __mips_fpr should be set to 0
that are not covered, ex. using o32 on a mips64 cpu
which is valid but not supported in the backend as of yet.

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

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

6 years ago[clang-tblgen] Add -print-records and -dump-json modes.
Simon Tatham [Wed, 22 Aug 2018 09:20:39 +0000 (09:20 +0000)]
[clang-tblgen] Add -print-records and -dump-json modes.

Currently, if clang-tblgen is run without a mode option, it defaults
to the first mode in its 'enum Action', which happens to be
-gen-clang-attr-classes. I think it makes more sense for it to behave
the same way as llvm-tblgen, i.e. print a diagnostic dump if it's not
given any more specific instructions.

I've also added the same -dump-json that llvm-tblgen supports. This
means any tblgen command line (whether llvm- or clang-) can be
mechanically turned into one that processes the same input into JSON.

Reviewers: nhaehnle

Reviewed By: nhaehnle

Subscribers: cfe-commits

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

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

6 years ago[AST] correct the behavior of -fvisibility-inlines-hidden option (don't make static...
Hiroshi Inoue [Wed, 22 Aug 2018 05:43:27 +0000 (05:43 +0000)]
[AST] correct the behavior of -fvisibility-inlines-hidden option (don't make static local variables hidden)

The command line option -fvisibility-inlines-hidden makes inlined method hidden, but it is expected not to affect the visibility of static local variables in the function.
However, Clang makes the static local variables in the function also hidden as reported in PR37595. This problem causes LLVM bootstarp failure on Fedora 28 if configured with -DBUILD_SHARED_LIBS=ON.

This patch makes the behavior of -fvisibility-inlines-hidden option to be consistent with that of gcc; the option does not change the visibility of the static local variables if the containing function does not associated with explicit visibility attribute and becomes hidden due to this option.

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

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

6 years ago[analyzer] [NFC] Fix minor formatting issues in RetainCountChecker
George Karpenkov [Wed, 22 Aug 2018 01:17:09 +0000 (01:17 +0000)]
[analyzer] [NFC] Fix minor formatting issues in RetainCountChecker

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

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

6 years ago[analyzer] [NFC] Extract a method for creating RefVal from RetEffect in RetainCountCh...
George Karpenkov [Wed, 22 Aug 2018 01:16:49 +0000 (01:16 +0000)]
[analyzer] [NFC] Extract a method for creating RefVal from RetEffect in RetainCountChecker

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

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

6 years agoUpdate the docs for using LLVM toolset in Visual Studio
Stephen Kelly [Wed, 22 Aug 2018 01:11:18 +0000 (01:11 +0000)]
Update the docs for using LLVM toolset in Visual Studio

Reviewers: hans

Subscribers: cfe-commits

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

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

6 years agoAdd space to TemplateArgument dump
Richard Trieu [Tue, 21 Aug 2018 22:55:26 +0000 (22:55 +0000)]
Add space to TemplateArgument dump

Add a missing space when dumping a template argument which is a template
expansion.  Found during debugging so no test.

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

6 years agoEliminate instances of `EmitScalarExpr(E->getArg(n))` in EmitX86BuiltinExpr().
Nico Weber [Tue, 21 Aug 2018 22:19:55 +0000 (22:19 +0000)]
Eliminate instances of `EmitScalarExpr(E->getArg(n))` in EmitX86BuiltinExpr().

EmitX86BuiltinExpr() emits all args into Ops at the beginning, so don't do that
work again.

This changes behavior: If e.g. ++a was passed as an arg, we incremented a twice
previously. This change fixes that bug.

https://reviews.llvm.org/D50979

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

6 years ago[CodeGen] Implicitly set stackrealign on the main function, if custom stack alignment...
Martin Storsjo [Tue, 21 Aug 2018 20:41:17 +0000 (20:41 +0000)]
[CodeGen] Implicitly set stackrealign on the main function, if custom stack alignment is used

If using a custom stack alignment, one is expected to make sure
that all callers provide such alignment, or realign the stack in
all entry points (and callbacks).

Despite this, the compiler can assume that the main function will
need realignment in these cases, since the startup routines calling
the main function most probably won't provide the custom alignment.

This matches what GCC does in similar cases; if compiling with
-mincoming-stack-boundary=X -mpreferred-stack-boundary=X, GCC normally
assumes such alignment on entry to a function, but specifically for
the main function still does realignment.

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

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

6 years agoAddress Aaron Ballman's post-commit review comments from r340306, NFC
Erik Pilkington [Tue, 21 Aug 2018 17:50:10 +0000 (17:50 +0000)]
Address Aaron Ballman's post-commit review comments from r340306, NFC

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

6 years agoAdd a new flag and attributes to control static destructor registration
Erik Pilkington [Tue, 21 Aug 2018 17:24:06 +0000 (17:24 +0000)]
Add a new flag and attributes to control static destructor registration

This commit adds the flag -fno-c++-static-destructors and the attributes
[[clang::no_destroy]] and [[clang::always_destroy]]. no_destroy specifies that a
specific static or thread duration variable shouldn't have it's destructor
registered, and is the default in -fno-c++-static-destructors mode.
always_destroy is the opposite, and is the default in -fc++-static-destructors
mode.

A variable whose destructor is disabled (either because of
-fno-c++-static-destructors or [[clang::no_destroy]]) doesn't count as a use of
the destructor, so we don't do any access checking or mark it referenced. We
also don't emit -Wexit-time-destructors for these variables.

rdar://21734598

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

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

6 years ago[ASTImporter] Add test for CXXNoexceptExpr
Raphael Isemann [Tue, 21 Aug 2018 17:15:57 +0000 (17:15 +0000)]
[ASTImporter] Add test for CXXNoexceptExpr

Reviewers: a.sidorin, a_sidorin

Reviewed By: a_sidorin

Subscribers: a_sidorin, hiraditya, martong, cfe-commits

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

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

6 years ago[Parser] Support alternative operator token keyword args in Objective-C++
Erik Pilkington [Tue, 21 Aug 2018 16:47:04 +0000 (16:47 +0000)]
[Parser] Support alternative operator token keyword args in Objective-C++

rdar://30741878

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

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

6 years ago[ASTImporter] Add test for CXXForRangeStmt
Raphael Isemann [Tue, 21 Aug 2018 16:36:49 +0000 (16:36 +0000)]
[ASTImporter] Add test for CXXForRangeStmt

Reviewers: a.sidorin, martong

Reviewed By: martong

Subscribers: rnkovacs, martong, cfe-commits

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

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

6 years agoAMDGPU: Move target code into TargetParser
Matt Arsenault [Tue, 21 Aug 2018 16:13:29 +0000 (16:13 +0000)]
AMDGPU: Move target code into TargetParser

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

6 years ago[clang][NFC] Fix typo in the name of a note
Louis Dionne [Tue, 21 Aug 2018 15:54:24 +0000 (15:54 +0000)]
[clang][NFC] Fix typo in the name of a note

Summary:
r306722 introduced a new note called note_silence_unligned_allocation_unavailable
where I believe what was meant is note_silence_aligned_allocation_unavailable.

Reviewers: ahatanak

Subscribers: dexonsmith, cfe-commits

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

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

6 years ago[analyzer] Correctly marked a virtual function 'override'
Kristof Umann [Tue, 21 Aug 2018 15:09:22 +0000 (15:09 +0000)]
[analyzer] Correctly marked a virtual function 'override'

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

6 years ago[ASTImporter] Adding some friend function related unittests.
Balazs Keri [Tue, 21 Aug 2018 14:32:21 +0000 (14:32 +0000)]
[ASTImporter] Adding some friend function related unittests.

Reviewers: a.sidorin, a_sidorin

Reviewed By: a_sidorin

Subscribers: a_sidorin, martong, cfe-commits

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

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

6 years ago[analyzer][UninitializedObjectChecker] Explicit namespace resolution for inherited...
Kristof Umann [Tue, 21 Aug 2018 12:16:59 +0000 (12:16 +0000)]
[analyzer][UninitializedObjectChecker] Explicit namespace resolution for inherited data members

For the following example:

  struct Base {
    int x;
  };

  // In a different translation unit

  struct Derived : public Base {
    Derived() {}
  };

For a call to Derived::Derived(), we'll receive a note that
this->x is uninitialized. Since x is not a direct field of Derived,
it could be a little confusing. This patch aims to fix this, as well
as the case when the derived object has a field that has the name as
an inherited uninitialized data member:

  struct Base {
    int x; // note: uninitialized field 'this->Base::x'
  };

  struct Derived : public Base {
    int x = 5;
    Derived() {}
  };

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

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

6 years agoAdd missing library dependency to fix build break after rC340247
Hiroshi Inoue [Tue, 21 Aug 2018 11:41:41 +0000 (11:41 +0000)]
Add missing library dependency to fix build break after rC340247

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

6 years ago[analyzer][UninitializedObjectChecker] Added documentation to the checker list
Kristof Umann [Tue, 21 Aug 2018 10:47:19 +0000 (10:47 +0000)]
[analyzer][UninitializedObjectChecker] Added documentation to the checker list

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

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

6 years ago[analyzer][UninitializedObjectChecker] Refactoring p6.: Move dereferencing to a function
Kristof Umann [Tue, 21 Aug 2018 10:45:21 +0000 (10:45 +0000)]
[analyzer][UninitializedObjectChecker] Refactoring p6.: Move dereferencing to a function

Now that it has it's own file, it makes little sense for
isPointerOrReferenceUninit to be this large, so I moved
dereferencing to a separate function.

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

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

6 years agoRemoved unused variable [NFC]
Mikael Holmen [Tue, 21 Aug 2018 07:22:45 +0000 (07:22 +0000)]
Removed unused variable [NFC]

The compiler warned:
../tools/clang/lib/Sema/SemaType.cpp:6788:31: error: unused variable 'AT' [-Werror,-Wunused-variable]
    if (const AttributedType *AT = S.getCallingConvAttributedType(type)) {
                              ^
1 error generated.

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

6 years ago[analyzer] [NFC] Split up RetainSummaryManager from RetainCountChecker - try #2
George Karpenkov [Tue, 21 Aug 2018 03:09:02 +0000 (03:09 +0000)]
[analyzer] [NFC] Split up RetainSummaryManager from RetainCountChecker - try #2

Turns out it can't be removed from the analyzer since it relies on CallEvent.

Moving to staticAnalyzer/core

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

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

6 years ago[WebAssembly] Revert type of wake count in atomic.wake to i32
Heejin Ahn [Mon, 20 Aug 2018 23:49:34 +0000 (23:49 +0000)]
[WebAssembly] Revert type of wake count in atomic.wake to i32

Summary:
We decided to revert this from i64 to i32 in Nov 28 CG meeting. Fixes
PR38632.

Reviewers: dschuff

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

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

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

6 years agolibclang: add install/distribution targets for python
Saleem Abdulrasool [Mon, 20 Aug 2018 22:50:18 +0000 (22:50 +0000)]
libclang: add install/distribution targets for python

Add installation support for the python bindings for libclang.  Add an
additional CMake configuration variable to enumerate the python versions for
which the bindings should be installed.  This allows for a LLVM/clang
distribution to distribute the python bindings for libclang as part of the
image.  Because the python versions need to be explicitly stated by the user,
the default image remains unchanged.

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

6 years ago[ASTImporter] Add test for C++'s try/catch statements.
Raphael Isemann [Mon, 20 Aug 2018 22:13:24 +0000 (22:13 +0000)]
[ASTImporter] Add test for C++'s try/catch statements.

Summary: Also enable exceptions in clang-import-test so that we can parse the test files.

Reviewers: a.sidorin, a_sidorin

Reviewed By: a_sidorin

Subscribers: a_sidorin, martong, cfe-commits

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

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

6 years agoModel type attributes as regular Attrs.
Richard Smith [Mon, 20 Aug 2018 21:47:29 +0000 (21:47 +0000)]
Model type attributes as regular Attrs.

Specifically, AttributedType now tracks a regular attr::Kind rather than
having its own parallel Kind enumeration, and AttributedTypeLoc now
holds an Attr* instead of holding an ad-hoc collection of Attr fields.

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

This reinstates r339623, reverted in r339638, with a fix to not fail
template instantiation if we instantiate a QualType with no associated
type source information and we encounter an AttributedType.

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

6 years agoDebugInfo: Add the ability to disable DWARF name tables entirely
David Blaikie [Mon, 20 Aug 2018 20:14:08 +0000 (20:14 +0000)]
DebugInfo: Add the ability to disable DWARF name tables entirely

This changes the current default behavior (from emitting pubnames by
default, to not emitting them by default) & moves to matching GCC's
behavior* with one significant difference: -gno(-gnu)-pubnames disables
pubnames even in the presence of -gsplit-dwarf (though -gsplit-dwarf
still by default enables -ggnu-pubnames). This allows users to disable
pubnames (& the new DWARF5 accelerated access tables) when they might
not be worth the size overhead.

* GCC's behavior is that -ggnu-pubnames and -gpubnames override each
other, and that -gno-gnu-pubnames and -gno-pubnames act as synonyms and
disable either kind of pubnames if they come last. (eg: -gpubnames
-gno-gnu-pubnames causes no pubnames (neither gnu or standard) to be
emitted)

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

6 years ago[Lex] Make HeaderMaps a unique_ptr vector
Fangrui Song [Mon, 20 Aug 2018 19:15:02 +0000 (19:15 +0000)]
[Lex] Make HeaderMaps a unique_ptr vector

Summary: unique_ptr makes the ownership clearer than a raw pointer container.

Reviewers: Eugene.Zelenko, dblaikie

Subscribers: cfe-commits

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

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

6 years agoRename -mlink-cuda-bitcode to -mlink-builtin-bitcode
Matt Arsenault [Mon, 20 Aug 2018 18:16:48 +0000 (18:16 +0000)]
Rename -mlink-cuda-bitcode to -mlink-builtin-bitcode

The same semantics work for OpenCL, and probably any offload
language. Keep the old name around as an alias.

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

6 years ago[OPENMP] Fix crash on the emission of the weak function declaration.
Alexey Bataev [Mon, 20 Aug 2018 18:03:40 +0000 (18:03 +0000)]
[OPENMP] Fix crash on the emission of the weak function declaration.

If the function is actually a weak reference, it should not be marked as
deferred definition as this is only a declaration. Patch adds checks for
the definitions if they must be emitted. Otherwise, only declaration is
emitted.

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

6 years agoClose FileEntries of cached files in ModuleManager::addModule().
Adrian Prantl [Mon, 20 Aug 2018 17:10:27 +0000 (17:10 +0000)]
Close FileEntries of cached files in ModuleManager::addModule().

While investigating why LLDB (which can build hundreds of clang
modules during one debug session) was getting "too many open files"
errors, I found that most of them are .pcm files that are kept open by
ModuleManager. Pretty much all of the open file dscriptors are
FileEntries that are refering to `.pcm` files for which a buffer
already exists in a CompilerInstance's PCMCache.

Before PCMCache was added it was necessary to hold on to open file
descriptors to ensure that all ModuleManagers using the same
FileManager read the a consistent version of a given `.pcm` file on
disk, even when a concurrent clang process overwrites the file halfway
through. The PCMCache makes this practice unnecessary, since it caches
the entire contents of a `.pcm` file, while the FileManager caches all
the stat() information.

This patch adds a call to FileEntry::closeFile() to the path where a
Buffer has already been created. This is necessary because even for a
freshly written `.pcm` file the file is stat()ed once immediately
after writing to generate a FileEntry in the FileManager. Because a
freshly-generated file's contents is stored in the PCMCache, it is
fine to close the file immediately thereafter.  The second change this
patch makes is to set the `ShouldClose` flag to true when reading a
`.pcm` file into the PCMCache for the first time.

[For reference, in 1 Clang instance there is
     - 1 FileManager and
     - n ModuleManagers with
     - n PCMCaches.]

rdar://problem/40906753

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

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

6 years ago[ASTImporter] Add test for C++ casts and fix broken const_cast importing.
Raphael Isemann [Mon, 20 Aug 2018 16:20:01 +0000 (16:20 +0000)]
[ASTImporter] Add test for C++ casts and fix broken const_cast importing.

Summary:
The ASTImporter does currently not handle const_casts. This patch adds the
missing const_cast importer code and the test case that discovered this.

Reviewers: a.sidorin, a_sidorin

Reviewed By: a_sidorin

Subscribers: a_sidorin, martong, cfe-commits

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

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

6 years ago[OPENMP][BLOCKS]Fix PR38923: reference to a global variable is captured
Alexey Bataev [Mon, 20 Aug 2018 16:00:22 +0000 (16:00 +0000)]
[OPENMP][BLOCKS]Fix PR38923: reference to a global variable is captured
by a block.

Added checks for capturing of the variable in the block when trying to
emit correct address for the variable with the reference type. This
extra check allows correctly identify the variables that are not
captured in the block context.

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

6 years ago[ASTImporter] Test for importing condition variable from a ForStmt
Raphael Isemann [Mon, 20 Aug 2018 15:51:41 +0000 (15:51 +0000)]
[ASTImporter] Test for importing condition variable from a ForStmt

Reviewers: a.sidorin, a_sidorin

Reviewed By: a_sidorin

Subscribers: cfe-commits, martong

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

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

6 years ago[NFC] Don't define static function in header (UninitializedObject.h)
Andrei Elovikov [Mon, 20 Aug 2018 13:45:38 +0000 (13:45 +0000)]
[NFC] Don't define static function in header (UninitializedObject.h)

Summary:
See also http://lists.llvm.org/pipermail/cfe-users/2016-January/000854.html for
the reasons why it's bad.

Reviewers: Szelethus, erichkeane

Reviewed By: Szelethus

Subscribers: cfe-commits

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

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

6 years ago[Lex] Fix some inconsistent parameter names and duplicate comments. NFC
Fangrui Song [Sun, 19 Aug 2018 22:23:42 +0000 (22:23 +0000)]
[Lex] Fix some inconsistent parameter names and duplicate comments. NFC

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

6 years ago[CodeGen] add test file that should have been included with r340141
Sanjay Patel [Sun, 19 Aug 2018 17:32:56 +0000 (17:32 +0000)]
[CodeGen] add test file that should have been included with r340141

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

6 years ago[CodeGen] add rotate builtins that map to LLVM funnel shift
Sanjay Patel [Sun, 19 Aug 2018 16:50:30 +0000 (16:50 +0000)]
[CodeGen] add rotate builtins that map to LLVM funnel shift
This is a partial retry of rL340137 (reverted at rL340138 because of gcc host compiler crashing)
with 1 change:
Remove the changes to make microsoft builtins also use the LLVM intrinsics.

This exposes the LLVM funnel shift intrinsics as more familiar bit rotation functions in clang
(when both halves of a funnel shift are the same value, it's a rotate).

We're free to name these as we want because we're not copying gcc, but if there's some other
existing art (eg, the microsoft ops) that we want to replicate, we can change the names.

The funnel shift intrinsics were added here:
https://reviews.llvm.org/D49242

With improved codegen in:
https://reviews.llvm.org/rL337966
https://reviews.llvm.org/rL339359

And basic IR optimization added in:
https://reviews.llvm.org/rL338218
https://reviews.llvm.org/rL340022

...so these are expected to produce asm output that's equal or better to the multi-instruction
alternatives using primitive C/IR ops.

In the motivating loop example from PR37387:
https://bugs.llvm.org/show_bug.cgi?id=37387#c7
...we get the expected 'rolq' x86 instructions if we substitute the rotate builtin into the source.

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

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

6 years ago[NEON] Define fp16 vld and vst intrinsics conditionally
Ivan A. Kosarev [Sun, 19 Aug 2018 16:30:57 +0000 (16:30 +0000)]
[NEON] Define fp16 vld and vst intrinsics conditionally

This patch fixes definitions of vld and vst NEON intrinsics so
that we only define them if half-precision arithmetic is
supported on the target platform, as prescribed in ACLE 2.0.

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

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

6 years agorevert r340137: [CodeGen] add rotate builtins
Sanjay Patel [Sun, 19 Aug 2018 15:31:42 +0000 (15:31 +0000)]
revert r340137: [CodeGen] add rotate builtins

At least a couple of bots (gcc host compiler on PPC only?) are showing the compiler dying while trying to compile.

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

6 years ago[CodeGen] add/fix rotate builtins that map to LLVM funnel shift (retry)
Sanjay Patel [Sun, 19 Aug 2018 14:44:47 +0000 (14:44 +0000)]
[CodeGen] add/fix rotate builtins that map to LLVM funnel shift (retry)

This is a retry of rL340135 (reverted at rL340136 because of gcc host compiler crashing)
with 2 changes:
1. Move the code into a helper to reduce code duplication (and hopefully work-around the crash).
2. The original commit had a formatting bug in the docs (missing an underscore).

Original commit message:

This exposes the LLVM funnel shift intrinsics as more familiar bit rotation functions in clang
(when both halves of a funnel shift are the same value, it's a rotate).

We're free to name these as we want because we're not copying gcc, but if there's some other
existing art (eg, the microsoft ops that are modified in this patch) that we want to replicate,
we can change the names.

The funnel shift intrinsics were added here:
https://reviews.llvm.org/D49242

With improved codegen in:
https://reviews.llvm.org/rL337966
https://reviews.llvm.org/rL339359

And basic IR optimization added in:
https://reviews.llvm.org/rL338218
https://reviews.llvm.org/rL340022

...so these are expected to produce asm output that's equal or better to the multi-instruction
alternatives using primitive C/IR ops.

In the motivating loop example from PR37387:
https://bugs.llvm.org/show_bug.cgi?id=37387#c7
...we get the expected 'rolq' x86 instructions if we substitute the rotate builtin into the source.

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

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

6 years agorevert r340135: [CodeGen] add rotate builtins
Sanjay Patel [Sun, 19 Aug 2018 13:48:06 +0000 (13:48 +0000)]
revert r340135: [CodeGen] add rotate builtins

At least a couple of bots (PPC only?) are showing the compiler dying while trying to compile:
http://lab.llvm.org:8011/builders/clang-ppc64be-linux-multistage/builds/11065/steps/build%20stage%201/logs/stdio
http://lab.llvm.org:8011/builders/clang-ppc64be-linux-lnt/builds/18267/steps/build%20stage%201/logs/stdio

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

6 years ago[CodeGen] add rotate builtins
Sanjay Patel [Sun, 19 Aug 2018 13:12:40 +0000 (13:12 +0000)]
[CodeGen] add rotate builtins

This exposes the LLVM funnel shift intrinsics as more familiar bit rotation functions in clang
(when both halves of a funnel shift are the same value, it's a rotate).

We're free to name these as we want because we're not copying gcc, but if there's some other
existing art (eg, the microsoft ops that are modified in this patch) that we want to replicate,
we can change the names.

The funnel shift intrinsics were added here:
D49242

With improved codegen in:
rL337966
rL339359

And basic IR optimization added in:
rL338218
rL340022

...so these are expected to produce asm output that's equal or better to the multi-instruction
alternatives using primitive C/IR ops.

In the motivating loop example from PR37387:
https://bugs.llvm.org/show_bug.cgi?id=37387#c7
...we get the expected 'rolq' x86 instructions if we substitute the rotate builtin into the source.

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

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

6 years agoRevert "[analyzer] [NFC] Split up RetainSummaryManager from RetainCountChecker"
Bruno Cardoso Lopes [Sat, 18 Aug 2018 03:22:11 +0000 (03:22 +0000)]
Revert "[analyzer] [NFC] Split up RetainSummaryManager from RetainCountChecker"

This reverts commit a786521fa66c72edd308baff0c08961b6d964fb1.

Bots haven't caught up yet, but broke modules build with:

../tools/clang/include/clang/StaticAnalyzer/Checkers/MPIFunctionClassifier.h:18:10:
fatal error: cyclic dependency in module 'Clang_StaticAnalyzer_Core':
Clang_StaticAnalyzer_Core -> Clang_Analysis ->
Clang_StaticAnalyzer_Checkers -> Clang_StaticAnalyzer_Core
         ^

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

6 years ago[analyzer] [NFC] Split up RetainSummaryManager from RetainCountChecker
George Karpenkov [Sat, 18 Aug 2018 01:45:50 +0000 (01:45 +0000)]
[analyzer] [NFC] Split up RetainSummaryManager from RetainCountChecker

ARCMigrator is using code from RetainCountChecker, which is a layering
violation (and it also does it badly, by using a different header, and
then relying on implementation being present in a header file).

This change splits up RetainSummaryManager into a separate library in
lib/Analysis, which can be used independently of a checker.

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

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

6 years agoQuickfix for failing tests.
George Karpenkov [Fri, 17 Aug 2018 23:54:00 +0000 (23:54 +0000)]
Quickfix for failing tests.

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

6 years ago[index] For an ObjC message call, also record as receivers the protocols if they...
Argyrios Kyrtzidis [Fri, 17 Aug 2018 23:50:59 +0000 (23:50 +0000)]
[index] For an ObjC message call, also record as receivers the protocols if they are present in the ObjC type

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

6 years ago[ObjC] Error out when using forward-declared protocol in a @protocol
Alex Lorenz [Fri, 17 Aug 2018 22:18:08 +0000 (22:18 +0000)]
[ObjC] Error out when using forward-declared protocol in a @protocol
expression

Clang emits invalid protocol metadata when a @protocol expression is used with a
forward-declared protocol. The protocol metadata is missing protocol conformance
list of the protocol since we don't have access to the definition of it in the
compiled translation unit. The linker then might end up picking the invalid
metadata when linking which will lead to incorrect runtime protocol conformance
checks.

This commit makes sure that Clang fails to compile code that uses a @protocol
expression with a forward-declared protocol. This ensures that Clang does not
emit invalid protocol metadata. I added an extra assert in CodeGen to ensure
that this kind of issue won't happen in other places.

rdar://32787811

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

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

6 years agoDon't warn on returning the address of a label from a statement expression
Reid Kleckner [Fri, 17 Aug 2018 22:11:31 +0000 (22:11 +0000)]
Don't warn on returning the address of a label from a statement expression

Summary:
There isn't anything inherently wrong with returning a label from a
statement expression. In practice, the Linux kernel uses this pattern to
materialize PCs.

Fixes PR38569

Reviewers: niravd, rsmith, nickdesaulniers

Subscribers: cfe-commits

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

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

6 years ago[analyzer] [NFC] Minor refactoring of ISL-specific code in RetainCountChecker
George Karpenkov [Fri, 17 Aug 2018 21:43:27 +0000 (21:43 +0000)]
[analyzer] [NFC] Minor refactoring of ISL-specific code in RetainCountChecker

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

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

6 years ago[analyzer] Re-instate support for MakeCollectable is RetainCountChecker
George Karpenkov [Fri, 17 Aug 2018 21:42:59 +0000 (21:42 +0000)]
[analyzer] Re-instate support for MakeCollectable is RetainCountChecker

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

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

6 years ago[analyzer] [NFC] Move ObjCRetainCount to include/Analysis
George Karpenkov [Fri, 17 Aug 2018 21:42:32 +0000 (21:42 +0000)]
[analyzer] [NFC] Move ObjCRetainCount to include/Analysis

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

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

6 years ago[analyzer] [NFC] Move canEval function from RetainCountChecker to RetainCountSummaries
George Karpenkov [Fri, 17 Aug 2018 21:42:05 +0000 (21:42 +0000)]
[analyzer] [NFC] Move canEval function from RetainCountChecker to RetainCountSummaries

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

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

6 years ago[analyzer] [NFC] Split up summary generation in RetainCountChecker in two methods
George Karpenkov [Fri, 17 Aug 2018 21:41:37 +0000 (21:41 +0000)]
[analyzer] [NFC] Split up summary generation in RetainCountChecker in two methods

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

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

6 years ago[analyzer] [NFC] Split up RetainCountChecker
George Karpenkov [Fri, 17 Aug 2018 21:41:07 +0000 (21:41 +0000)]
[analyzer] [NFC] Split up RetainCountChecker

At some point, staring at 4k+ LOC file becomes a bit hard.

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

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

6 years ago[analyzer] Drop support for GC mode in RetainCountChecker
George Karpenkov [Fri, 17 Aug 2018 21:40:38 +0000 (21:40 +0000)]
[analyzer] Drop support for GC mode in RetainCountChecker

A lot of code in RetainCountChecker deals with GC mode.
Given that GC mode is deprecated, Apple does not ship runtime for it,
and modern compiler toolchain does not support it, it makes sense to
remove the code dealing with it in order to aid understanding of
RetainCountChecker.

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

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

6 years agotest commit: add a comment
Mike Rice [Fri, 17 Aug 2018 21:16:21 +0000 (21:16 +0000)]
test commit: add a comment

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

6 years agoUpdate comments in CGDebugInfo to reflect changes in the MS mangler, NFC
Reid Kleckner [Fri, 17 Aug 2018 20:59:52 +0000 (20:59 +0000)]
Update comments in CGDebugInfo to reflect changes in the MS mangler, NFC

I've tried to elaborate on the purpose of these type identifiers and why
and when clang uses them.

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

6 years ago[MS] Mangle a hash of the main file path into anonymous namespaces
Reid Kleckner [Fri, 17 Aug 2018 20:59:27 +0000 (20:59 +0000)]
[MS] Mangle a hash of the main file path into anonymous namespaces

Summary:
This is needed to avoid conflicts in mangled names for codeview types in
anonymous namespaces. In CodeView, types refer to each other typically
through forward declarations, which contain mangled names. These names
have to be unique, otherwise the debugger will look up the mangled name
and find the wrong definition.

Furthermore, ThinLTO will deduplicate the types, and debug info
verification can fail when the types have the wrong sizes. This is
PR38608.

Fixes PR38609.

Reviewers: majnemer, inglorion, hans

Subscribers: mehdi_amini, aprantl, JDevlieghere, dexonsmith, cfe-commits

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

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

6 years agoImprove diagnostic for missing comma in template parameter list.
Richard Smith [Fri, 17 Aug 2018 19:43:40 +0000 (19:43 +0000)]
Improve diagnostic for missing comma in template parameter list.

Given 'typename T typename U', we would correctly diagnose the missing
comma, but incorrectly disambiguate the first parameter as being a
non-type parameter and complain that the 'T' is not a qualified-id.

See also gcc.gnu.org/PR86998.

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