Commit Graph

74900 Commits

Author SHA1 Message Date
Vedant Kumar ee6c233ae0 [InstrProf] Use atomic profile counter updates for TSan
Thread sanitizer instrumentation fails to skip all loads and stores to
profile counters. This can happen if profile counter updates are merged:

  %.sink = phi i64* ...
  %pgocount5 = load i64, i64* %.sink
  %27 = add i64 %pgocount5, 1
  %28 = bitcast i64* %.sink to i8*
  call void @__tsan_write8(i8* %28)
  store i64 %27, i64* %.sink

To suppress TSan diagnostics about racy counter updates, make the
counter updates atomic when TSan is enabled. If there's general interest
in this mode it can be surfaced as a clang/swift driver option.

Testing: check-{llvm,clang,profile}

rdar://40477803

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

llvm-svn: 339955
2018-08-16 22:24:47 +00:00
David Blaikie 19763d93fd Update for LLVM API change
llvm-svn: 339941
2018-08-16 21:30:24 +00:00
Matt Arsenault 89e833c662 AMDGPU: Correct errors in device table
llvm-svn: 339934
2018-08-16 20:19:47 +00:00
Emmett Neyman 70657f65ef Update README and Dockerfile to include llvm-proto-fuzzer
Summary: Added commands to Dockerfile to build llvm-proto-fuzzer and the other related tools. Also added a section to the bottom of the README describing what llvm-proto-fuzzer does and how to run it.

Reviewers: morehouse, kcc

Reviewed By: morehouse

Subscribers: cfe-commits, llvm-commits

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

llvm-svn: 339933
2018-08-16 20:13:40 +00:00
Raphael Isemann db33cf2533 [ASTImporter] Add test for member pointer types.
Reviewers: a.sidorin, martong

Reviewed By: martong

Subscribers: rnkovacs, martong, cfe-commits

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

llvm-svn: 339919
2018-08-16 18:22:21 +00:00
Raphael Isemann 5440fee09f [ASTImporter] Add test for importing CompoundAssignOperators
Reviewers: a.sidorin, martong

Reviewed By: martong

Subscribers: rnkovacs, cfe-commits, martong

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

llvm-svn: 339918
2018-08-16 18:21:33 +00:00
Raphael Isemann 5fd7f152c8 [ASTImporter] Add test for DoStmt
Reviewers: a.sidorin, martong

Reviewed By: martong

Subscribers: rnkovacs, martong, cfe-commits

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

llvm-svn: 339917
2018-08-16 18:20:52 +00:00
Raphael Isemann 2fd6e45e67 [ASTImporter] Add test for WhileStmt
Reviewers: a.sidorin, martong

Reviewed By: martong

Subscribers: rnkovacs, martong, cfe-commits

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

llvm-svn: 339916
2018-08-16 18:20:05 +00:00
Raphael Isemann 003140d1b2 [ASTImporter] Add test for IndirectGotoStmt
Reviewers: a.sidorin, martong

Reviewed By: martong

Subscribers: rnkovacs, martong, cfe-commits

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

llvm-svn: 339915
2018-08-16 18:19:21 +00:00
Bruno Ricci d6bd5983ee [AST] Store the OwnedTagDecl as a trailing object in ElaboratedType.
The TagDecl *OwnedTagDecl in ElaboratedType is quite commonly
null (at least when parsing all of Boost, it is non-null for only about 600
of the 66k ElaboratedType). Therefore we can save a pointer in the
common case by storing it as a trailing object, and storing a bit in the
bit-fields of Type indicating when the pointer is null.

Reviewed By: rjmccall

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

llvm-svn: 339862
2018-08-16 10:48:16 +00:00
Bruno Ricci 08672ecef9 [AST] Pack the unsigned of SubstTemplateTypeParmPackType into Type
The bit-fields of Type have enough space for the member
unsigned NumArgs of SubstTemplateTypeParmPackType.

Reviewed By: erichkeane

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

llvm-svn: 339861
2018-08-16 10:33:36 +00:00
Bruno Ricci e3b87c3df5 [AST] Pack the unsigned of DependentTemplateSpecializationType into Type
The bit-fields of `Type` have enough space for the member
`unsigned NumArgs` of `DependentTemplateSpecializationType`.

Reviewed By: erichkeane

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

llvm-svn: 339860
2018-08-16 10:28:18 +00:00
Craig Topper 72a7606433 [X86] Remove masking from the 512-bit paddus/psubus builtins. Use a select builtin instead.
llvm-svn: 339845
2018-08-16 07:28:06 +00:00
Craig Topper 0609d1e211 [X86] Remove masking from the 512-bit padds and psubs builtins. Use select builtin instead.
llvm-svn: 339843
2018-08-16 06:20:29 +00:00
Raphael Isemann eca7cbe009 [ASTImporter] Add test for CXXDefaultInitExpr
Reviewers: a.sidorin, a_sidorin

Reviewed By: a_sidorin

Subscribers: a_sidorin, martong, cfe-commits

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

llvm-svn: 339839
2018-08-16 01:37:43 +00:00
Raphael Isemann 1038fa61ec [ASTImporter] Add test for CXXScalarValueInit
Reviewers: a.sidorin, a_sidorin

Reviewed By: a_sidorin

Subscribers: martong, cfe-commits

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

llvm-svn: 339838
2018-08-16 01:36:37 +00:00
Raphael Isemann 85504a9ca6 [ASTImporter] Add test for ForStmt and ContinueStmt
Reviewers: a.sidorin, a_sidorin

Reviewed By: a_sidorin

Subscribers: martong, cfe-commits

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

llvm-svn: 339837
2018-08-16 01:35:47 +00:00
Petr Hosek bc86a99f78 [Driver] -print-target-triple and -print-effective-triple options
These can be used to print Clang target and effective triple.

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

llvm-svn: 339834
2018-08-16 00:22:03 +00:00
Emmett Neyman ba58c3a3a5 Implementation of nested loops in cxx_loop_proto
Summary: Extended `cxx_loop_proto` to have neste for loops. Modified `loop_proto_to_llvm` and `loop_proto_to_cxx` to handle the new protos. All protos have a set of statements designated as "inner loop" statements and a set of statements designated as "outer loop" statements.

Reviewers: morehouse, kcc

Reviewed By: morehouse

Subscribers: cfe-commits, llvm-commits

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

llvm-svn: 339832
2018-08-15 23:05:48 +00:00
Raphael Isemann e5715ff997 [ASTImporter] Add test for ArrayInitLoopExpr
Reviewers: a.sidorin, a_sidorin

Reviewed By: a_sidorin

Subscribers: martong, cfe-commits

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

llvm-svn: 339831
2018-08-15 22:52:21 +00:00
Raphael Isemann 380e372b13 [ASTImporter] Add test for ExprWithCleanups
Reviewers: a.sidorin, a_sidorin

Reviewed By: a_sidorin

Subscribers: a_sidorin, martong, cfe-commits

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

llvm-svn: 339830
2018-08-15 22:51:37 +00:00
Chris Bieneman 9ff2d7d56a [Darwin Driver] Fix Simulator builtins and test cases
In r339807, I broke linking the builtins libraries for simulator targets, which itself was bad, but turns out it was all completely untested and marked with FIXME in the test suite.

This fixes all the test cases so they actually work, and fixes the bug I introduced in r339807.

llvm-svn: 339829
2018-08-15 22:50:06 +00:00
Raphael Isemann f78af0c9a4 [ASTImporter] Add test for IfStmt
Reviewers: a.sidorin, hiraditya

Reviewed By: hiraditya

Subscribers: hiraditya, martong, cfe-commits

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

llvm-svn: 339827
2018-08-15 22:36:58 +00:00
Stephen Kelly 3124ce724a Add a newline to SourceLocation dump output
Summary:
Migrate callers to print().

dump() should be useful to downstreams and third parties as a debugging
aid.  Everyone trips up on this and creates confusing output.

Subscribers: cfe-commits

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

llvm-svn: 339810
2018-08-15 20:32:06 +00:00
David Carlier 6a691a0b7c [CStringSyntaxChecker] Reduces space around error message for strlcat.
llvm-svn: 339808
2018-08-15 20:09:52 +00:00
Chris Bieneman 3434ade2b7 Refactor Darwin driver to refer to runtimes by component
Summary:
In r335809, Petr Hosek lays out support for what he calls the multiarch
runtimes layout. This new way of laying out the directories for runtime
libraries is workable for all platforms. Petr did some of the common
infrastructure and made it work for Linux and Fuscia. This patch is a
cleanup to the Darwin and MachO drivers to serve as a step toward
supporting it in Darwin.

This patch does primarily two things:
(1) Changes the APIs for how the Darwin driver refers to compiler-rt
libraries to use the component names, similar to how Linux and Fuscia do

(2) Removes some legacy functionality for supporting macOS versions
before 10.6. This functionality is effectively dead code because in
r339277, the support was removed from compiler-rt for generating the 10.4
runtime support library, and Xcode 10 (currently in beta) removes
libgcc_s.10.4 and libgcc_s.10.5 from the macOS SDK.

With this patch landed a subsequent patch can modify
MachO::AddLinkRuntimeLib to support the multiarch runtimes layout.

Worth noting: None of the removed functionality was actually covered in
the test suite. So no test case updates are required.

Reviewers: phosek, bruno, arphaman

Reviewed By: phosek, arphaman

Subscribers: cfe-commits

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

llvm-svn: 339807
2018-08-15 20:09:38 +00:00
Alexey Bataev d01b74974b [OPENMP] FIx processing of declare target variables.
The compiler may produce unexpected error messages/crashes when declare
target variables were used. Patch fixes problems with the declarations
marked as declare target to or link.

llvm-svn: 339805
2018-08-15 19:45:12 +00:00
Daniel Jasper 67e6521a67 clang-format: Change Google style wrt. the formatting of empty messages.
Before:
  message Empty {
  }

After:
  message Empty {}

llvm-svn: 339803
2018-08-15 19:07:55 +00:00
Bruno Ricci 58e577cb25 [AST] Pack the unsigned of PackExpansionType into Type
The bit-fields of `Type` have enough space for
the `unsigned NumExpansions` of `PackExpansionType`

Reviewed By: erichkeane

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

llvm-svn: 339789
2018-08-15 16:28:58 +00:00
Bruno Ricci 43ccc1c63d [AST] Pack the bits of TemplateSpecializationType into Type
Type has enough space for two members of
TemplateSpecializationType. Mechanical patch.

Reviewed By: erichkeane

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

llvm-svn: 339787
2018-08-15 16:21:17 +00:00
Momchil Velikov 9e5e045b60 Use .cpp extension for certain tests instead of .cc
The tests `CodeGen/aapcs[64]-align.cc` are not run since files with a `.cc`
suffix aren't recognisze as tests. This patch renames the above two files to
`.cpp`.

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

Comitting as obvious.

llvm-svn: 339766
2018-08-15 12:22:08 +00:00
David Green db63228a5c Fix ASTMatchersTraversalTest testcase compile on older compilers
Some versions of gcc, especially when invoked through ccache (-E), can have
trouble with raw string literals inside macros. This moves the string out of
the macro.

llvm-svn: 339759
2018-08-15 10:39:43 +00:00
Richard Smith 33d8b95ef6 Silence "unused variable" warning.
llvm-svn: 339747
2018-08-15 01:06:30 +00:00
Artem Dergachev 3ccf14eb8e [analyzer] Add support for constructors of arguments.
Once CFG-side support for argument construction contexts landed in r338436,
the analyzer could make use of them to evaluate argument constructors properly.

When evaluated as calls, constructors of arguments now use the variable region
of the parameter as their target. The corresponding stack frame does not yet
exist when the parameter is constructed, and this stack frame is created
eagerly.

Construction of functions whose body is unavailable and of virtual functions
is not yet supported. Part of the reason is the analyzer doesn't consistently
use canonical declarations o identify the function in these cases, and every
re-declaration or potential override comes with its own set of parameter
declarations. Also it is less important because if the function is not
inlined, there's usually no benefit in inlining the argument constructor.

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

llvm-svn: 339745
2018-08-15 00:33:55 +00:00
Stephen Kelly cb5b433798 Remove obsolete comment
This related to the code as first checked in in r266292 ([ASTImporter]
Implement some expression-related AST node import., 2016-04-14).

llvm-svn: 339731
2018-08-14 21:34:29 +00:00
Stephen Kelly 0945c8b942 Fix Stmt::ignoreImplicit
Summary:
A CXXBindTemporaryExpr can appear inside an ImplicitCastExpr, and was
not ignored previously.

Fixes the case reported in PR37327.

Reviewers: rsmith, dblaikie, klimek

Subscribers: cfe-commits

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

llvm-svn: 339730
2018-08-14 21:33:28 +00:00
Reid Kleckner b8c29d538b Fix lit fatal errors about requiring a USE_Z3_SOLVER param
llvm-svn: 339728
2018-08-14 21:15:57 +00:00
Artem Dergachev c531d54967 [CFG] [analyzer] Find argument constructors in CXXTemporaryObjectExprs.
CXXTemporaryObjectExpr is a sub-class of CXXConstructExpr. If it has arguments
that are structures passed by value, their respective constructors need to be
handled by providing a ConstructionContext, like for regular function calls and
for regular constructors.

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

llvm-svn: 339727
2018-08-14 21:10:46 +00:00
Artem Dergachev bf33a2cdf2 [analyzer] Add a test forgotten in r339088.
Differential Revision: https://reviews.llvm.org/D50363

llvm-svn: 339726
2018-08-14 21:06:30 +00:00
Craig Topper 2a87314e75 [InlineAsm] Update the min-legal-vector-width function attribute based on inputs and outputs to inline assembly
Summary:
Another piece of my ongoing to work for prefer-vector-width.

min-legal-vector-width will eventually be used by the X86 backend to know whether it needs to make 512 bits type legal when prefer-vector-width=256. If the user used inline assembly that passed in/out a 512-bit register, we need to make sure 512 bits are considered legal. Otherwise we'll get an assert failure when we try to wire up the inline assembly to the rest of the code.

This patch just checks the LLVM IR types to see if they are vectors and then updates the attribute based on their total width. I'm not sure if this is the best way to do this or if there's any subtlety I might have missed. So if anyone has other opinions on how to do this I'm open to suggestions.

Reviewers: chandlerc, rsmith, rnk

Reviewed By: rnk

Subscribers: eraman, cfe-commits

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

llvm-svn: 339721
2018-08-14 20:21:05 +00:00
Vlad Tsyrklevich 97e6819e79 SafeStack: Disable Darwin support
Summary:
Darwin support does not appear to be used as evidenced by the fact that
the runtime has never supported non-trivial programs.

Reviewers: pcc, kubamracek

Reviewed By: pcc

Subscribers: cfe-commits, kcc

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

llvm-svn: 339720
2018-08-14 19:50:41 +00:00
George Karpenkov a1e55d252e [analyzer] Fix bots by removing new check-clang-analyzer commands from CHECK-ALL
llvm-svn: 339709
2018-08-14 18:55:34 +00:00
Alexey Bataev 97b722121e [OPENMP] Fix processing of declare target construct.
The attribute marked as inheritable since OpenMP 5.0 supports it +
additional fixes to support new functionality.

llvm-svn: 339704
2018-08-14 18:31:20 +00:00
Kevin P. Neal 2c0bc8b7a3 We have in place support for parsing #pragma FENV_ACCESS, but that
information is then discarded with a warning to the user that we don't 
support it.

This patch gets us one step closer by getting the info down into the 
AST in most cases.

Reviewed by:	rsmith
Differential Revision:	https://reviews.llvm.org/D49865

llvm-svn: 339693
2018-08-14 17:06:56 +00:00
Kevin P. Neal da4c67f0a9 Revert test commit
llvm-svn: 339691
2018-08-14 16:57:10 +00:00
Kevin P. Neal 51f6e7ef83 Test commit
llvm-svn: 339690
2018-08-14 16:56:25 +00:00
Sven van Haastregt 22d57d9bec [OpenCL] Add test for constant sampler argument
llvm-svn: 339678
2018-08-14 13:56:52 +00:00
David Chisnall c66d480bce [gnu-objc] Make selector order deterministic.
Summary:
This probably fixes PR35277, though there may be other sources of
nondeterminism (this was the only case of iterating over a DenseMap).

It's difficult to provide a test case for this, because it shows up only
on systems with ASLR enabled.

Reviewers: rjmccall

Reviewed By: rjmccall

Subscribers: bmwiedemann, mgrang, cfe-commits

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

llvm-svn: 339668
2018-08-14 10:05:25 +00:00
David Chisnall 060a789c84 Add a stub mangling for ObjC selectors in the Microsoft ABI.
This mangling is used only for outlined SEH finally blocks, which have
internal linkage.

This fixes the failure of CodeGenObjC/2007-04-03-ObjcEH.m on builds with
expensive checks enabled, on Windows.  This test should probably be
specifying a triple: it currently picks up whatever the host environment
is using.  Unfortunately, I have no idea what it is trying to test,
because it contains no comments and predates Clang having working
Objective-C IR generation.

llvm-svn: 339667
2018-08-14 10:04:36 +00:00
Dean Michael Berris 661cc1e104 [XRay][clang] Add more test cases of -fxray-modes= (NFC)
This confirms expectations for multiple values provided through the
driver when selecting specific modes and the order of appearance of
individual values for the `-fxray-modes=` flag.

This change just adds more test cases to an existing test file.

llvm-svn: 339662
2018-08-14 09:16:37 +00:00
Kristof Umann 3e3f7552eb [analyzer] Made a buildbot happy.
llvm-svn: 339655
2018-08-14 08:38:35 +00:00
Kristof Umann 5a42441d81 [analyzer][UninitializedObjectChecker] Void pointers are casted back to their dynamic type in note message
Differential Revision: https://reviews.llvm.org/D49228

llvm-svn: 339653
2018-08-14 08:20:51 +00:00
Tomasz Krupa e8cf972d86 [X86] Lowering addus/subus intrinsics to native IR
Summary: This is the patch that lowers x86 intrinsics to native IR in order to enable optimizations.

Reviewers: craig.topper, spatel, RKSimon

Reviewed By: craig.topper

Subscribers: cfe-commits

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

llvm-svn: 339651
2018-08-14 08:01:38 +00:00
David Carlier 54fc3767fc [CStringSyntaxChecker] Check strlcat sizeof check
- Assuming strlcat is used with strlcpy we check as we can if the last argument does not equal os not larger than the buffer.
- Advising the proper usual pattern.

Reviewers: NoQ, george.karpenkov

Reviewed By: george.karpenkov

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

llvm-svn: 339641
2018-08-14 05:12:53 +00:00
Reid Kleckner 11f9f8acde Revert r339623 "Model type attributes as regular Attrs."
This breaks compiling atlwin.h in Chromium. I'm sure the code is invalid
in some way, but we put a lot of work into accepting it, and I'm sure
rejecting it was not an intended consequence of this refactoring. :)

llvm-svn: 339638
2018-08-14 01:55:37 +00:00
Richard Smith 5b2636142a Move test inputs into Inputs directory.
We don't need a new ExpectedOutputs/ convention. Expected outputs are
just another form of test input.

llvm-svn: 339634
2018-08-14 00:18:48 +00:00
Akira Hatanaka 936240c77a [CodeGen] Before returning a copy/dispose helper function, bitcast it to
a void pointer type.

This fixes a bug introduced in r339438.

llvm-svn: 339633
2018-08-14 00:15:42 +00:00
Akira Hatanaka e67e3c8045 Fix check strings in test/CodeGenObjC/arc-blocks.m in preperation for
fixing a bug introduced in r339438.

Check the descriptor global variables in the IR at both -O0 and -O2.

llvm-svn: 339632
2018-08-14 00:15:41 +00:00
George Karpenkov e3b1d96218 [analyzer] Fix UninitializedObjectChecker to not crash on uninitialized "id" fields
Differential Revision: https://reviews.llvm.org/D50673

llvm-svn: 339631
2018-08-13 23:32:15 +00:00
George Karpenkov 2997a3042e [analyzer] [NFC] Introduce separate targets for testing the analyzer: check-clang-analyzer and check-clang-analyzer-z3
Current testing setup for analyzer tests with Z3 is rather inconvenient:

There's no way to run the analyzer tests separately (I use
LIT_FILTER=Analysis ninja check-clang, but a direct target is nicer).

When Clang is built with Z3 support, there's no way to *not* run tests
with Z3 solver, and this is often desired, as tests with Z3 solver take
a very long time.

This patch introduces two extra targets:

 - check-clang-analyzer
 - check-clang-analyzer-z3

which solve those problems.

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

llvm-svn: 339629
2018-08-13 23:12:43 +00:00
Richard Smith 651d683ee3 Fix Clang warnings and bad #include filenames in r339595 and r339599.
llvm-svn: 339624
2018-08-13 22:07:11 +00:00
Richard Smith f79178635a 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

llvm-svn: 339623
2018-08-13 22:07:09 +00:00
Akira Hatanaka 4a6f190e19 Convert if/else to a switch. NFC.
llvm-svn: 339613
2018-08-13 20:59:57 +00:00
Alexey Bataev f138fda5ed [OPENMP] Fix emission of the loop doacross constructs.
The number of loops associated with the OpenMP loop constructs should
not be considered as the number loops to collapse.

llvm-svn: 339603
2018-08-13 19:04:24 +00:00
Kristof Umann 23ca9660bf [analyzer][UninitializedObjectChecker] Refactoring p5.: Handle pedantic mode in the checker class only
Differential Revision: https://reviews.llvm.org/D50508

llvm-svn: 339601
2018-08-13 18:48:34 +00:00
Kristof Umann 015b059569 [analyzer][UninitializedObjectChecker] Refactoring p4.: Wrap FieldRegions and reduce weight on FieldChainInfo
Before this patch, FieldChainInfo used a spaghetti: it took care of way too many cases,
even though it was always meant as a lightweight wrapper around
ImmutableList<const FieldRegion *>.
This problem is solved by introducing a lightweight polymorphic wrapper around const
FieldRegion *, FieldNode. It is an interface that abstracts away special cases like
pointers/references, objects that need to be casted to another type for a proper note
messages.

Changes to FieldChainInfo:

  * Now wraps ImmutableList<const FieldNode &>.
  * Any pointer/reference related fields and methods were removed
  * Got a new add method. This replaces it's former constructors as a way to create a
    new FieldChainInfo objects with a new element.

Changes to FindUninitializedField:

  * In order not to deal with dynamic memory management, when an uninitialized field is
    found, the note message for it is constructed and is stored instead of a
    FieldChainInfo object. (see doc around addFieldToUninits).

Some of the test files are changed too, from now on uninitialized pointees of references
always print "uninitialized pointee" instead of "uninitialized field" (which should've
really been like this from the beginning).

I also updated every comment according to these changes.

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

llvm-svn: 339599
2018-08-13 18:43:08 +00:00
Erich Keane 0fb16483ac Enforce instantiation of template multiversion functions
Multiversioned member functions inside of a template type were 
not properly being emitted.  The solution to this is to simply 
ensure that their bodies are correctly evaluated/assigned during
template instantiation.

llvm-svn: 339597
2018-08-13 18:33:20 +00:00
Kristof Umann a37bba4727 [analyzer][UninitializedObjectChecker] Refactoring p3.: printTail moved out from FieldChainInfo
This is a standalone part of the effort to reduce FieldChainInfos inteerface.

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

llvm-svn: 339596
2018-08-13 18:22:22 +00:00
Kristof Umann 56963aec8b [analyzer][UninitializedObjectChecker] Refactoring p2.: Moving pointer chasing to a separate file
In this patch, the following classes and functions have been moved to a header file:

    FieldChainInfo
    FindUninitializedFields
    isPrimitiveType

This also meant that they moved from anonymous namespace to clang::ento.

Code related to pointer chasing now relies in its own file.

There's absolutely no functional change in this patch -- its literally just copy pasting.

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

llvm-svn: 339595
2018-08-13 18:17:05 +00:00
Nick Desaulniers 1a3caef148 [Sema] fix -Wfloat-conversion test case.
Summary:
Fixes r339581 ("[SEMA] add more -Wfloat-conversion to
compound assigment analysis").

This test case was caught in postsubmit testing.

Reviewers: aaron.ballman, gkistanova

Reviewed By: aaron.ballman

Subscribers: cfe-commits, srhines

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

llvm-svn: 339593
2018-08-13 18:07:50 +00:00
Kristof Umann ea7cb67581 [analyzer][UninitializedObjectChecker] Refactoring p1.: ImmutableList factory is no longer static
This patch is the first part of a series of patches to refactor UninitializedObjectChecker. The goal of this effort is to

    Separate pointer chasing from the rest of the checker,
    Increase readability and reliability,
    Don't impact performance (too bad).

In this one, ImmutableList's factory is moved to FindUninitializedFields.

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

llvm-svn: 339591
2018-08-13 17:55:52 +00:00
Bruno Ricci 4e34c65ffd [AST] Update/correct the static_asserts for the bit-fields in Type
The current static_assert only checks that ObjCObjectTypeBitfields
fits into an unsigned. However it turns out that FunctionTypeBitfields
do not currently fits into an unsigned. Therefore the anonymous
union containing the bit-fields always use 8 bytes instead of 4.

This patch removes the lone misguided static_assert and systematically
checks the size of each bit-field.

Reviewed By: erichkeane

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

llvm-svn: 339582
2018-08-13 16:40:57 +00:00
Nick Desaulniers 1aaf524ea1 [SEMA] add more -Wfloat-conversion to compound assigment analysis
Summary: Fixes Bug: https://bugs.llvm.org/show_bug.cgi?id=27061

Reviewers: aaron.ballman, acoomans

Reviewed By: aaron.ballman, acoomans

Subscribers: acoomans, cfe-commits, srhines, pirama

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

llvm-svn: 339581
2018-08-13 16:38:07 +00:00
Alexey Bataev 23647171ea Revert "[OPENMP] Fix emission of the loop doacross constructs."
This reverts commit r339568 because of the problems with the buildbots.

llvm-svn: 339574
2018-08-13 14:42:18 +00:00
Krasimir Georgiev d2a36bdf09 [clang-format] Fix comment, NFC
llvm-svn: 339573
2018-08-13 14:32:29 +00:00
Martin Bohme 4e1293b5e1 Summary:Add clang::reinitializes attribute
Summary:
This is for use by clang-tidy's bugprone-use-after-move check -- see
corresponding clang-tidy patch at https://reviews.llvm.org/D49910.

Reviewers: aaron.ballman, rsmith

Reviewed By: aaron.ballman

Subscribers: cfe-commits

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

llvm-svn: 339569
2018-08-13 14:11:03 +00:00
Alexey Bataev 0ce6360e0e [OPENMP] Fix emission of the loop doacross constructs.
The number of loops associated with the OpenMP loop constructs should
not be considered as the number loops to collapse.

llvm-svn: 339568
2018-08-13 14:05:43 +00:00
Balazs Keri 0c23dc59fc [ASTImporter] Improved import of friend templates.
Summary:
When importing a friend class template declaration,
this declaration should not be merged with any other existing declaration
for the same type. Otherwise the getFriendDecl of the FriendDecl can point
to an other already referenced declaration, this case causes problems.
Additionally the previous decl of class templates is set at import.

Reviewers: a.sidorin, a_sidorin

Reviewed By: a_sidorin

Subscribers: a_sidorin, martong, cfe-commits

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

llvm-svn: 339560
2018-08-13 13:08:37 +00:00
Haojian Wu 74e0f40d98 Revert "Allow relockable scopes with thread safety attributes."
This reverts commit r339456.

The change introduces a new crash, see

class SCOPED_LOCKABLE FileLock {
 public:
  explicit FileLock()
      EXCLUSIVE_LOCK_FUNCTION(file_);
  ~FileLock() UNLOCK_FUNCTION(file_);
  void Lock() EXCLUSIVE_LOCK_FUNCTION(file_);
  Mutex file_;
};

void relockShared2() {
  FileLock file_lock;
  file_lock.Lock();
}

llvm-svn: 339558
2018-08-13 12:50:30 +00:00
Kadir Cetinkaya 9b9c27490d [clang] Store code completion token range in preprocessor.
Summary:
This change is to support a new fature in clangd, tests will be send toclang-tools-extra with that change.

Unittests are included in: https://reviews.llvm.org/D50449

Reviewers: ilya-biryukov

Reviewed By: ilya-biryukov

Subscribers: ioeric, MaskRay, jkorous, arphaman, cfe-commits

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

llvm-svn: 339540
2018-08-13 08:13:35 +00:00
Shuai Wang 3b2a17bd1d [ASTMatchers] Let hasAnyArgument also support CXXUnresolvedConstructExpr
Subscribers: cfe-commits

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

llvm-svn: 339530
2018-08-12 23:30:05 +00:00
Aaron Ballman 8cd96484d2 Renaming arg_const_range to const_arg_range; NFC.
This form makes more sense (it is a range over constant arguments) and is most consistent with const_arg_iterator (there are zero instances of arg_const_iterator).

llvm-svn: 339527
2018-08-12 21:19:22 +00:00
Shuai Wang 72b56ed6b4 [ASTMatchers] Add matchers unresolvedMemberExpr, cxxDependentScopeMemberExpr
Subscribers: cfe-commits

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

llvm-svn: 339522
2018-08-12 17:34:36 +00:00
Raphael Isemann 612c524a90 [ASTImporter] Added test case for opaque enums
Reviewers: a.sidorin, a_sidorin

Reviewed By: a_sidorin

Subscribers: a_sidorin, martong, cfe-commits

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

llvm-svn: 339506
2018-08-11 23:43:46 +00:00
Raphael Isemann 30e0c43c17 [ASTImporter] Added test case for CXXConversionDecl importing
Reviewers: a.sidorin, a_sidorin

Reviewed By: a_sidorin

Subscribers: a_sidorin, martong, cfe-commits

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

llvm-svn: 339505
2018-08-11 23:43:02 +00:00
Douglas Yung 9b6cd711d6 Make the section boundary checks on Windows not depend on the order as they are emitted in reverse when the compiler is built by Visual C++.
llvm-svn: 339494
2018-08-11 02:46:47 +00:00
George Karpenkov b3fff18638 [analyzer] Fix keyboard navigation for .msgNote events
Does not go to msgNote's.

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

llvm-svn: 339493
2018-08-11 01:47:41 +00:00
Reka Kovacs bb2749a594 [analyzer] InnerPointerChecker: improve warning messages and notes.
Differential Revision: https://reviews.llvm.org/D49570

llvm-svn: 339489
2018-08-10 23:56:57 +00:00
George Karpenkov 2537972f25 [analyzer] [NFC] [tests] Move plist-based diagnostics tests to separate files, use diff instead of a FileCheck - II
Some files were missed by https://reviews.llvm.org/D50545

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

llvm-svn: 339488
2018-08-10 23:51:43 +00:00
George Karpenkov e99ba6e1f9 [analyzer] Record nullability implications on getting items from NSDictionary
If we get an item from a dictionary, we know that the item is non-null
if and only if the key is non-null.

This patch is a rather hacky way to record this implication, because
some logic needs to be duplicated from the solver.
And yet, it's pretty simple, performant, and works.

Other possible approaches:

 - Record the implication, in future rely on Z3 to pick it up.
 - Generalize the current code and move it to the constraint manager.

rdar://34990742

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

llvm-svn: 339482
2018-08-10 22:27:04 +00:00
George Karpenkov b5dd3ccdbd [analyzer] Fix tracking expressions through negation operator
Differential Revision: https://reviews.llvm.org/D50537

llvm-svn: 339476
2018-08-10 21:42:19 +00:00
George Karpenkov 09a9e3abfe [analyzer] [NFC] [tests] Move plist-based diagnostics tests to separate files, use diff instead of a FileCheck
Some of the analyzer tests check the exact plist output, in order to
verify that the diagnostics produced is correct.
Current testing setup has many issues:

plist output clobbers tests, making them harder to read
it is impossible to debug test failures given error messages from FileCheck.
The only recourse is manually creating the files and using the diff
again, it is impossible to update the tests given the error message:
the only process is a tedious manual one,
going from a separate plist file to CHECK directives.

This patch offers a much better approach of using "diff" directly in place of FileCheck,
and moving tests to separate files.

Generated using the following script:

```
import os
import glob
import re
import subprocess

diagnostics_key = "// CHECK:  <key>diagnostics</key>"

def process_file(f, data):
    idx = data.index(diagnostics_key)
    plist_out_f = 'ExpectedOutputs/plists/%s.plist' % f
    plist_out_folder = os.path.join('ExpectedOutputs/plists/', os.path.dirname(f))
    plist_data = data[idx:]
    plist_data = plist_data.replace('// CHECK: ', '')
    plist_data = plist_data.replace('// CHECK-NEXT: ', '')
    plist_data += "</dict>\n</plist>\n"
    data = data[:idx]

    ptn = re.compile("FileCheck --?input-file(=| )(%t|%t\.plist) %s")

    if not ptn.findall(data):
        print "none found =/ skipping..."
        return

    data = ptn.sub(lambda m: "tail -n +11 %s | diff -u -w - %%S/../%s" % (m.group(2), plist_out_f), data)

    with open(f, 'w') as out_f:
        out_f.write(data)

    subprocess.check_call(["mkdir", "-p", plist_out_folder])
    with open(plist_out_f, 'w') as out_f:
        out_f.write(plist_data)

def main():
    files = glob.glob("**/*.*")
    for f in files:
        with open(f) as f_handler:
            data = f_handler.read()
        if diagnostics_key in data:
            print "Converting %s" %f
            process_file(f, data)

if __name__ == "__main__":
    main()
```

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

llvm-svn: 339475
2018-08-10 21:36:45 +00:00
George Karpenkov 088adbfa16 Invalidate static locals when escaping lambdas
Lambdas can affect static locals even without an explicit capture.

rdar://39537031

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

llvm-svn: 339459
2018-08-10 18:28:04 +00:00
Aaron Ballman a97e4dc899 Allow relockable scopes with thread safety attributes.
Patch by Aaron Puchert

llvm-svn: 339456
2018-08-10 17:33:47 +00:00
Akira Hatanaka f60082a038 Make changes to the check strings so that the test I modified in r339438
passes on 32-bit targets.

llvm-svn: 339452
2018-08-10 17:07:27 +00:00
Akira Hatanaka 9978da3615 [CodeGen] Merge equivalent block copy/helper functions.
Clang generates copy and dispose helper functions for each block literal
on the stack. Often these functions are equivalent for different blocks.
This commit makes changes to merge equivalent copy and dispose helper
functions and reduce code size.

To enable merging equivalent copy/dispose functions, the captured object
infomation is encoded into the helper function name. This allows IRGen
to check whether an equivalent helper function has already been emitted
and reuse the function instead of generating a new helper function
whenever a block is defined. In addition, the helper functions are
marked as linkonce_odr to enable merging helper functions that have the
same name across translation units and marked as unnamed_addr to enable
the linker's deduplication pass to merge functions that have different
names but the same content.

rdar://problem/42640608

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

llvm-svn: 339438
2018-08-10 15:09:24 +00:00
David Chisnall b3c11504bd Fix a deprecated warning in the last commit.
Done as a separate commit to make it easier to cherry pick the changes
to the release branch.

llvm-svn: 339429
2018-08-10 12:53:18 +00:00
David Chisnall 93ce018f3d Add Windows support for the GNUstep Objective-C ABI V2.
Summary:
Introduces funclet-based unwinding for Objective-C and fixes an issue
where global blocks can't have their isa pointers initialised on
Windows.

After discussion with Dustin, this changes the name mangling of
Objective-C types to prevent a C++ catch statement of type struct X*
from catching an Objective-C object of type X*.

Reviewers: rjmccall, DHowett-MSFT

Reviewed By: rjmccall, DHowett-MSFT

Subscribers: mgrang, mstorsjo, smeenai, cfe-commits

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

llvm-svn: 339428
2018-08-10 12:53:13 +00:00
Hans Wennborg abb71f90d5 clang-cl: accept -fcrash-diagnostics-dir=
llvm-svn: 339424
2018-08-10 11:40:50 +00:00
Bruno Ricci 802d559bb4 Fix a wrong type bug in ParsedAttr::TypeTagForDatatypeData
This patch fixes a wrong type bug inside ParsedAttr::TypeTagForDatatypeData.
The details to the best of my knowledge are as follow. The incredible thing
is that everything works out just fine by chance due to a sequence of lucky
coincidences in the layout of various types.

The struct ParsedAttr::TypeTagForDatatypeData contains among other things
a ParsedType *MatchingCType, where ParsedType is just OpaquePtr<QualType>.

However the member MatchingCType is initialized in the constructor for
type_tag_for_datatype attribute as follows:

new (&ExtraData.MatchingCType) ParsedType(matchingCType);

This results in the ParsedType being constructed in the location of the
ParsedType * Later ParsedAttr::getMatchingCType do return
*getTypeTagForDatatypeDataSlot().MatchingCType; which instead of
dereferencing the ParsedType * will dereference the QualType inside
the ParsedType. Now this QualType in this case contains no qualifiers
and therefore is a valid Type *. Therefore getMatchingCType returns a
Type or at least the stuff that is in the first sizeof(void*) bytes of it,
But it turns out that Type inherits from ExtQualsCommonBase and that the
first member of ExtQualsCommonBase is a const Type *const BaseType. This
Type * in this case points to the original Type pointed to by the
QualType and so everything works fine even though all the types were wrong.

This bug was only found because I changed the layout of Type,
which obviously broke all of this long chain of improbable events.

Reviewed By: erichkeane

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

llvm-svn: 339423
2018-08-10 11:20:20 +00:00