Commit Graph

54286 Commits

Author SHA1 Message Date
Oliver Stannard d83a559318 [AArch64] Support selecting TPIDR_EL[1-3] as the thread base
Add an -mtp=el[0-3] option to select which of the AArch64 thread ID registers
will be used for the TLS base pointer.

This is a followup to rL356657 which added subtarget features to enable
accesses to the privileged thread ID registers.

Patch by Philip Derrin!

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

llvm-svn: 357250
2019-03-29 13:32:41 +00:00
Michael Liao ce38992a30 [Sema] Fix a crash when nonnull checking
Summary:
- If a parameter is used, nonnull checking needs function prototype to
  retrieve the corresponding parameter's attributes. However, at the
  prototype substitution phase when a template is being instantiated,
  expression may be created and checked without a fully specialized
  prototype. Under such a scenario, skip nonnull checking on that
  argument.

Reviewers: rjmccall, tra, yaxunl

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

Tags: #clang

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

llvm-svn: 357236
2019-03-29 03:55:52 +00:00
Akira Hatanaka 8b8d362313 [CodeGen][ObjC] Adjust the addresses passed to calls to synthesized
copy/move constructor/assignment operator functions for non-trivial C
structs.

This commit fixes a bug where the offset of struct fields weren't being
taken into account when computing the addresses passed to calls to the
special functions.

For example, the copy constructor for S1 (__copy_constructor_8_8_s0_s8)
would pass the start addresses of the destination and source structs to
the call to S0's copy constructor (_copy_constructor_8_8_s0) without
adding the offset of field f1 to the addresses.

typedef struct {
  id f0;
  S0 f1;
} S1;

void test(S1 s1) {
  S1 t = s1;
}

rdar://problem/49400610

llvm-svn: 357229
2019-03-29 00:23:20 +00:00
Akira Hatanaka 801cc3272a Fix typos and formatting. NFC.
llvm-svn: 357228
2019-03-29 00:23:17 +00:00
Reid Kleckner 73253bdefc [MS] Make __iso_volatile_* available on all targets
Future versions of MSVC make these intrinsics available on x86 & x64,
according to:
http://lists.llvm.org/pipermail/cfe-dev/2019-March/061711.html

The purpose of these builtins is to emit plain, non-atomic, volatile
stores when /volatile:ms (-cc1 -fms-volatile) is enabled.

llvm-svn: 357220
2019-03-28 22:59:09 +00:00
Alexey Bataev 471171c4c9 [OPENMP]Add check for undefined behavior with thread allocators on
target and task-based directives.

According to OpenMP 5.0, 2.11.4 allocate Clause, Restrictions, For task,
taskloop or target directives, allocation requests to memory allocators
with the trait access set to thread result in unspecified behavior.
Patch introduces a check for omp_thread_mem_alloc predefined allocator
on target- and trask-based directives.

llvm-svn: 357205
2019-03-28 19:15:36 +00:00
Dan Albert 2715b28716 [Driver] Default Android toolchains to noexecstack.
Android does not support executable stacks.

Reviewers: srhines, pirama

Reviewed By: pirama

Subscribers: cfe-commits

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

llvm-svn: 357197
2019-03-28 18:08:28 +00:00
Sam Clegg fc5ddeeab3 [WebAssembly] Reland of rL356953 (4dcf3acce6)
The previous patch was missing GetProgramPath() in the return value
of getLinkerPath().

See https://reviews.llvm.org/D59743

llvm-svn: 357195
2019-03-28 17:45:18 +00:00
Benjamin Kramer ba2ea93ad1 Make helper functions static. NFC.
llvm-svn: 357187
2019-03-28 17:18:42 +00:00
Shoaib Meenai 155e26f0f4 [CodeGen] Add additional mangling for struct members of non trivial structs
In https://bugs.llvm.org/show_bug.cgi?id=41206 we observe bad codegen
when embedding a non-trivial C struct within a C struct. This is due to
the fact that name mangling for non-trivial structs marks the two
structs as identical. This diff contains a fix for this issue.

Patch by Dan Zimmerman <daniel.zimmerman@me.com>.

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

llvm-svn: 357184
2019-03-28 17:01:20 +00:00
Adam Balogh a19c985f8a [Analyzer] Constraint Manager - Calculate Effective Range for Differences
Since rL335814, if the constraint manager cannot find a range set for `A - B`
(where `A` and `B` are symbols) it looks for a range for `B - A` and returns
it negated if it exists. However, if a range set for both `A - B` and `B - A`
is stored then it only returns the first one. If we both use `A - B` and
`B - A`, these expressions behave as two totally unrelated symbols. This way
we miss some useful deductions which may lead to false negatives or false
positives.

This tiny patch changes this behavior: if the symbolic expression the
constraint manager is looking for is a difference `A - B`, it tries to
retrieve the range for both `A - B` and `B - A` and if both exists it returns
the intersection of range `A - B` and the negated range of `B - A`. This way
every time a checker applies new constraints to the symbolic difference or to
its negated it always affects both the original difference and its negated.

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

llvm-svn: 357167
2019-03-28 13:05:59 +00:00
Anastasia Stulova 314fab6d7f [PR41247] Fixed parsing of private keyword in C++.
Fixed bug in C++ to prevent parsing 'private' as a
valid address space qualifier.

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

llvm-svn: 357162
2019-03-28 11:47:14 +00:00
Fangrui Song ee957e045f [Driver] Allow -gsplit-dwarf on ELF OSes other than Linux and Fuchsia
In gcc, -gsplit-dwarf is handled in gcc/gcc.c as a spec
(ASM_FINAL_SPEC): objcopy --extract-dwo + objcopy --strip-dwo. In
gcc/opts.c, -gsplit_dwarf has the same semantic of a -g. Except for the
availability of the external command 'objcopy', nothing precludes the
feature working on other ELF OSes. llvm doesn't use objcopy, so it doesn't
have to exclude other OSes.

llvm-svn: 357150
2019-03-28 08:24:00 +00:00
Derek Schuff 039be78791 Revert "[WebAssembly] Don't use default GetLinkerPath"
This reverts commit 4dcf3acce6.
(reverts LLVM SVN r356953)

llvm-svn: 357127
2019-03-27 22:22:18 +00:00
Shafik Yaghmour e5094d6d3d [ASTImporter] Fix IsStructuralMatch specialization for EnumDecl to prevent re-importing an EnumDecl while trying to complete it
Summary:
We may try and re-import an EnumDecl while trying to complete it in IsStructuralMatch(...) specialization for EnumDecl. This change mirrors a similar fix for the specialization for RecordDecl.

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

llvm-svn: 357100
2019-03-27 17:47:36 +00:00
Alexey Bataev e04483ee35 [OPENMP]Initial support for 'allocate' clause.
Added parsing/sema analysis of the allocate clause.

llvm-svn: 357068
2019-03-27 14:14:31 +00:00
George Rimar 36d71da694 Revert the r348352 "[clang] - Simplify tools::SplitDebugName."
This partially reverts the r348352 (https://reviews.llvm.org/D55006)
because of https://bugs.llvm.org/show_bug.cgi?id=41161.

I did not revert the test case file because it passes fine now.

llvm-svn: 357061
2019-03-27 11:00:03 +00:00
Erik Pilkington 818698010c Emit -Wfortify-source using DiagRuntimeBehaviour
This fixes a false positive on the following, where st is configured to have
different sizes based on some preprocessor logic:

  if (sizeof(buf) == sizeof(*st))
    memcpy(&buf, st, sizeof(*st));

llvm-svn: 357041
2019-03-26 23:21:22 +00:00
Erik Pilkington 14f6d1527c [Sema] Fix an assert when a block captures a constexpr local
MarkVarDeclODRUsed indirectly calls captureInBlock, which creates a copy
expression. The copy expression is insulated in it's own
ExpressionEvaluationContext, so it saves, mutates, and restores MaybeODRUseExprs
as CleanupVarDeclMarking is iterating through it, leading to a crash. Fix this
by iterating through a local copy of MaybeODRUseExprs.

rdar://47493525

https://reviews.llvm.org/D59670

llvm-svn: 357040
2019-03-26 23:21:19 +00:00
Duncan P. N. Exon Smith db8a742206 Basic: Return a reference from FileManager::getVirtualFileSystem, NFC
FileManager constructs a VFS in its constructor if it isn't passed one,
and there's no way to reset it.  Make that contract clear by returning a
reference from its accessor.

https://reviews.llvm.org/D59388

llvm-svn: 357038
2019-03-26 22:32:06 +00:00
Duncan P. N. Exon Smith 1da7eac87c Frontend: Remove CompilerInstance::VirtualFileSystem, NFC
Remove CompilerInstance::VirtualFileSystem and
CompilerInstance::setVirtualFileSystem, instead relying on the VFS in
the FileManager.  CompilerInstance and its clients already went to some
trouble to make these match.  Now they are guaranteed to match.

As part of this, I added a VFS parameter (defaults to nullptr) to
CompilerInstance::createFileManager, to avoid repeating construction
logic in clients that just wanted to customize the VFS.

https://reviews.llvm.org/D59377

llvm-svn: 357037
2019-03-26 22:18:52 +00:00
Jessica Paquette 55d495475c Make -mno-outline pass -enable-machine-outliner=never to ld in LTO
Since AArch64 has default outlining behaviour, we need to make sure that
-mno-outline is actually passed along to the linker in this case. Otherwise,
it will run by default on minsize functions even when -mno-outline is specified.

Also fix the darwin-ld test for this, which wasn't actually doing anything.

llvm-svn: 357031
2019-03-26 21:22:42 +00:00
Ronald Wampler a83e2dbb1e [clang-format] Add style option AllowShortLambdasOnASingleLine
Summary:
This option `AllowShortLambdasOnASingleLine` similar to the other `AllowShort*` options, but applied to C++ lambdas.

Reviewers: djasper, klimek

Reviewed By: klimek

Subscribers: MyDeveloperDay, cfe-commits

Tags: #clang

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

llvm-svn: 357027
2019-03-26 20:18:14 +00:00
Fangrui Song 9d568e29b7 [CodeGen] Delete never used LValueAlign
It was added by rC176658 but never used since then.

llvm-svn: 357001
2019-03-26 15:39:45 +00:00
Anastasia Stulova 545652b964 [OpenCL] Allow variadic macros as Clang feature.
llvm-svn: 356987
2019-03-26 11:22:37 +00:00
Roger Ferrer Ibanez e41a74e8d2 [RISCV] Pass -target-abi to -cc1as
The RISC-V assembler needs the target ABI because it defines a flag of the ELF
file, as described in [1].

Make clang (the driver) to pass the target ABI to -cc1as in exactly the same
way it does for -cc1.

Currently -cc1as knows about -target-abi but is not handling it. Handle it and
pass it to the MC layer via MCTargetOptions.

[1] https://github.com/riscv/riscv-elf-psabi-doc/blob/master/riscv-elf.md#file-header

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

llvm-svn: 356981
2019-03-26 08:01:18 +00:00
Artem Dergachev bef9f8aac3 [CFG] [analyzer] pr41142: C++17: Skip transparent InitListExprs in ExprEngine.
r356634 didn't fix all the problems caused by r356222 - even though simple
constructors involving transparent init-list expressions are now evaluated
precisely, many more complicated constructors aren't, for other reasons.

The attached test case is an example of a constructor that will never be
evaluated precisely - simply because there isn't a constructor there (instead,
the program invokes run-time undefined behavior by returning without a return
statement that should have constructed the return value).

Fix another part of the problem for such situations: evaluate transparent
init-list expressions transparently, so that to avoid creating ill-formed
"transparent" nonloc::CompoundVals.

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

llvm-svn: 356969
2019-03-26 00:36:53 +00:00
Reid Kleckner 1181c9f45d [MS] Add frontend support for __declspec(allocator)
The intention is to add metadata to direct call sites of functions
marked with __declspec(allocator), which will ultimately result in some
S_HEAPALLOCSITE debug info records when emitting codeview.

This is a piece of PR38491

llvm-svn: 356964
2019-03-25 23:20:18 +00:00
Bruno Ricci 95550e412f [Sema] Don't check for array bounds when the types in the base expression are dependent
Bail-out of CheckArrayAccess when the types of the base expression before
and after eventual casts are dependent. We will get another chance to check
for array bounds during instantiation. Fixes PR41087.

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

Reviewed By: efriedma

llvm-svn: 356957
2019-03-25 21:37:10 +00:00
Sam Clegg 4dcf3acce6 [WebAssembly] Don't use default GetLinkerPath
We can't (don't want to) honor the same set of "-fuse-ld" flags with
WebAssembly since the ELF linkers (ld.lld, ld.gnu, etc) don't work with
wasm object files.

Instead we implement our own linker finding logic, similar or other
non-ELF platforms like MSVC.

We've had a few issues with CLANG_DEFAULT_LINKER overriding the
WebAssembly linker which doesn't make sense since there is no generic
linker that can handle WebAssembly today.

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

llvm-svn: 356953
2019-03-25 21:14:26 +00:00
Konstantin Zhuravlyov ec28a1dcef AMDGPU: Add support for cross address space synchronization scopes (clang)
Differential Revision: https://reviews.llvm.org/D59494

llvm-svn: 356947
2019-03-25 20:54:00 +00:00
JF Bastien cefafc4999 Thread Safety: also look at ObjC methods
Summary:
SExprBuilder::translateDeclRefExpr was only looking at FunctionDecl and not also looking at ObjCMethodDecl. It should consider both because the attributes can be used on Objective-C as well.

<rdar://problem/48941331>

Reviewers: dexonsmith, erik.pilkington

Subscribers: jkorous, jdoerfert, cfe-commits

Tags: #clang

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

llvm-svn: 356940
2019-03-25 20:06:32 +00:00
Sylvestre Ledru a199a9ba40 clang -dumpversion returns 4.2.1 for legacy reason, update it
Summary:
It has been introduced in 2011 for gcc compat:
95a907fc0f
it is probably time to remove it to remove the confusion.

reported: https://bugs.llvm.org/show_bug.cgi?id=38836
https://bugs.launchpad.net/ubuntu/+source/llvm-defaults/+bug/1810860

Reviewers: ddunbar, rnk

Reviewed By: rnk

Subscribers: jdoerfert, cfe-commits

Tags: #clang

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

llvm-svn: 356931
2019-03-25 18:06:20 +00:00
Mikhail R. Gadelha db695c834f Moved everything SMT-related to LLVM and updated the cmake scripts.
Differential Revision: https://reviews.llvm.org/D54978

llvm-svn: 356929
2019-03-25 17:47:45 +00:00
Krasimir Georgiev fc67176eec [clang-format] Refine structured binding detection
Summary:
Revision r356575 had the unfortunate consequence that now clang-format never
detects an ObjC call expression after `&&`.

This patch tries harder to distinguish between C++17 structured bindings and
ObjC call expressions and adds a few regression tests.

Reviewers: klimek

Reviewed By: klimek

Subscribers: cfe-commits

Tags: #clang

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

llvm-svn: 356928
2019-03-25 17:29:16 +00:00
Bruno Ricci 70ad396bc4 [Sema][NFCI] Don't allocate storage for the various CorrectionCandidateCallback unless we are going to do some typo correction
The various CorrectionCandidateCallbacks are currently heap-allocated
unconditionally. This was needed because of delayed typo correction.
However these allocations represent currently 15.4% of all allocations
(number of allocations) when parsing all of Boost (!), mostly because
of ParseCastExpression, ParseStatementOrDeclarationAfterAttrtibutes
and isCXXDeclarationSpecifier. Note that all of these callback objects
are small. Let's not do this.

Instead initially allocate the callback on the stack, and only do a
heap allocation if we are going to do some typo correction. Do this by:

1. Adding a clone function to each callback, which will do a polymorphic
   clone of the callback. This clone function is required to be implemented
   by every callback (of which there is a fair amount). Make sure this is
   the case by making it pure virtual.

2. Use this clone function when we are going to try to correct a typo.

This additionally cut the time of -fsyntax-only on all of Boost by 0.5%
(not that much, but still something). No functional changes intended.

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

Reviewed By: rnk

llvm-svn: 356925
2019-03-25 17:08:51 +00:00
Haojian Wu ae3fefe397 Revert "[clang-format] Keep protobuf "package" statement on one line"
This reverts commit r356835. This patch causes a regression, see the
test below:

verifyFormat("// Detached comment\n\n"
             "// Leading comment\n"
             "syntax = \"proto2\"; // trailing comment\n\n"
             "// in foo.bar package\n"
             "package foo.bar; // foo.bar package\n");

llvm-svn: 356912
2019-03-25 15:46:07 +00:00
Anastasia Stulova 948e37c8ca [OpenCL] Allow addr space spelling without __ prefix in C++.
For backwards compatibility we allow alternative spelling of address
spaces - 'private', 'local', 'global', 'constant', 'generic'.

In order to accept 'private' correctly, parsing has been changed to
understand different use cases - access specifier vs address space.

Fixes PR40707 and PR41011!

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

llvm-svn: 356888
2019-03-25 11:54:02 +00:00
Balazs Keri 57949eb677 [ASTImporter] Changed use of Import to Import_New in ASTNodeImporter.
Reviewers: a.sidorin, shafik, martong, a_sidorin

Reviewed By: a_sidorin

Subscribers: a_sidorin, rnkovacs, gamesh411, dkrupp, martong, Szelethus, cfe-commits

Tags: #clang

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

llvm-svn: 356874
2019-03-25 09:16:39 +00:00
Brian Gesiak b15c35aff8 Un-revert "[coroutines][PR40978] Emit error for co_yield within catch block"
Summary:
https://reviews.llvm.org/D59076 added a new coroutine error that
prevented users from using 'co_await' or 'co_yield' within a exception
handler. However, it was reverted in https://reviews.llvm.org/rC356774
because it caused a regression in nested scopes in C++ catch statements,
as documented by https://bugs.llvm.org/show_bug.cgi?id=41171.

The issue was due to an incorrect use of a `clang::ParseScope`. To fix:

1. Add a regression test for catch statement parsing that mimics the bug
   report from https://bugs.llvm.org/show_bug.cgi?id=41171.
2. Re-apply the coroutines error patch from
   https://reviews.llvm.org/D59076, but this time with the correct
   ParseScope behavior.

Reviewers: GorNishanov, tks2103, rsmith, riccibruno, jbulow

Reviewed By: riccibruno

Subscribers: EricWF, jdoerfert, lewissbaker, cfe-commits

Tags: #clang

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

llvm-svn: 356865
2019-03-25 00:53:10 +00:00
Craig Topper 6af0363857 [X86] Make _bswap intrinsic a function instead of a macro to hopefully fix the chromium build.
This intrinsic was added in r356848 but was implemented as a macro to match gcc.

llvm-svn: 356862
2019-03-24 18:00:20 +00:00
Craig Topper 88f4054f48 [X86] Add BSR/BSF/BSWAP intrinsics to ia32intrin.h to match gcc.
Summary:
These are all implemented by icc as well.

I made bit_scan_forward/reverse forward to the __bsfd/__bsrq since we also have
__bsfq/__bsrq.

Note, when lzcnt is enabled the bsr intrinsics generates lzcnt+xor instead of bsr.

Reviewers: RKSimon, spatel

Subscribers: cfe-commits, llvm-commits

Tags: #clang

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

llvm-svn: 356848
2019-03-24 00:56:52 +00:00
Simon Pilgrim 1ba406c9fc Fix unused variable warning. NFCI.
llvm-svn: 356839
2019-03-23 16:16:46 +00:00
Paul Hoad f5e52738fe [clang-format] Keep protobuf "package" statement on one line
Summary:
Top-level "package" and "import" statements should generally be kept on one
line, for all languages.

Reviewers: sammccall, krasimir, MyDeveloperDay

Reviewed By: MyDeveloperDay

Subscribers: MyDeveloperDay, cfe-commits

Tags: #clang

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

Patch By: dchai (Donald Chai)

llvm-svn: 356835
2019-03-23 14:43:41 +00:00
Paul Hoad c6deae4521 Clang-format: add finer-grained options for putting all arguments on one line
Summary:
Add two new options,
AllowAllArgumentsOnNextLine and
AllowAllConstructorInitializersOnNextLine.  These mirror the existing
AllowAllParametersOfDeclarationOnNextLine and allow me to support an
internal style guide where I work.  I think this would be generally
useful, some have asked for it on stackoverflow:

https://stackoverflow.com/questions/30057534/clang-format-binpackarguments-not-working-as-expected

https://stackoverflow.com/questions/38635106/clang-format-how-to-prevent-all-function-arguments-on-next-line

Reviewers: djasper, krasimir, MyDeveloperDay

Reviewed By: MyDeveloperDay

Subscribers: jkorous, MyDeveloperDay, aol-nnov, lebedev.ri, uohcsemaj, cfe-commits, klimek

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

Patch By: russellmcc  (Russell McClellan)

llvm-svn: 356834
2019-03-23 14:37:58 +00:00
Paul Hoad a87ba1c59c [clang-format] correctly format protobuf fields named "enum".
Summary: Similar to TypeScript, "enum" is not a reserved word.

Reviewers: krasimir, MyDeveloperDay

Reviewed By: MyDeveloperDay

Subscribers: MyDeveloperDay, cfe-commits

Tags: #clang, #clang-tools-extra

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

Patch by: dchai (Donald Chai)

llvm-svn: 356833
2019-03-23 14:24:30 +00:00
Peter Collingbourne d1c5b28c2a IRGen: Remove StructorType; thread GlobalDecl through more code. NFCI.
This should make it easier to add more structor variants.

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

llvm-svn: 356822
2019-03-22 23:05:10 +00:00
Thomas Lively 80ff58e37c [WebAssembly] Make driver -pthread imply linker --shared-memory
Summary:
This eliminates a linker error the user might otherwise see about how
using the 'atomics' feature requires --shared-memory.

Reviewers: sbc100, aheejin

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

Tags: #clang

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

llvm-svn: 356817
2019-03-22 22:25:37 +00:00
Carey Williams 2c3c9ca4ba [ARM] Fix bug 39982 - pcs("aapcs-vfp") is not consistent
Correctly handle homogeneous aggregates when a
function's ABI is specified via the pcs attribute.

Bug: https://bugs.llvm.org/show_bug.cgi?id=39982
Differential Revision: https://reviews.llvm.org/D59094

llvm-svn: 356776
2019-03-22 16:20:45 +00:00
Brian Gesiak e8b3d63dd5 Revert "[coroutines][PR40978] Emit error for co_yield within catch block"
The commit https://reviews.llvm.org/rC356296 is causing a regression in nested
catch scopes, https://bugs.llvm.org/show_bug.cgi?id=41171. Revert this change
for now in order to un-break that problem report.

llvm-svn: 356774
2019-03-22 16:08:29 +00:00