]> granicus.if.org Git - clang/log
clang
5 years agoRevert "[analyzer] Introduce a simplified API for adding custom path notes."
Artem Dergachev [Fri, 29 Mar 2019 23:11:10 +0000 (23:11 +0000)]
Revert "[analyzer] Introduce a simplified API for adding custom path notes."

This reverts commit r357323.

ASan leaks found by a buildbot :)

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

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

5 years ago[analyzer] PR41239: Fix a crash on invalid source location in NoStoreFuncVisitor.
Artem Dergachev [Fri, 29 Mar 2019 22:57:49 +0000 (22:57 +0000)]
[analyzer] PR41239: Fix a crash on invalid source location in NoStoreFuncVisitor.

It turns out that SourceManager::isInSystemHeader() crashes when an invalid
source location is passed into it. Invalid source locations are relatively
common: not only they come from body farms, but also, say, any function in C
that didn't come with a forward declaration would have an implicit
forward declaration with invalid source locations.

There's a more comfy API for us to use in the Static Analyzer:
CallEvent::isInSystemHeader(), so just use that.

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

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

5 years ago[analyzer] Move taint API from ProgramState to a separate header. NFC.
Artem Dergachev [Fri, 29 Mar 2019 22:49:30 +0000 (22:49 +0000)]
[analyzer] Move taint API from ProgramState to a separate header. NFC.

It is now an inter-checker communication API, similar to the one that
connects MallocChecker/CStringChecker/InnerPointerChecker: simply a set of
setters and getters for a state trait.

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

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

5 years ago[analyzer] PR37501: Disable assertion for logical op short circuit evaluation.
Artem Dergachev [Fri, 29 Mar 2019 22:43:34 +0000 (22:43 +0000)]
[analyzer] PR37501: Disable assertion for logical op short circuit evaluation.

The transfer function for the CFG element that represents a logical operation
computes the value of the operation and does nothing else. The element
appears after all the short circuit decisions were made, so they don't need
to be made again at this point.

Because our expression evaluation is imprecise, it is often hard to
discriminate between:

  (1) we don't know the value of the RHS because we failed to evaluate it

and

  (2) we don't know the value of the RHS because it didn't need to be evaluated.

This is hard because it depends on our knowledge about the value of the LHS
(eg., if LHS is true, then RHS in (LHS || RHS) doesn't need to be computed)
but LHS itself may have been evaluated imprecisely and we don't know whether
it is true or not. Additionally, the Analyzer wouldn't necessarily even remember
what the value of the LHS was because theoretically it's not really necessary
to know it for any future evaluations.

In order to work around these issues, the transfer function for logical
operations consists in looking at the ExplodedGraph we've constructed so far
in order to figure out from which CFG direction did we arrive here.
Such post-factum backtracking that doesn't involve looking up LHS and RHS values
is usually possible. However sometimes it fails because when we deduplicate
exploded nodes with the same program point and the same program state we may end
up in a situation when we reached the same program point from two or more
different directions.

By removing the assertion, we admit that the procedure indeed sometimes fails to
work. When it fails, we also admit that we don't know the value of the logical
operator.

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

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

5 years ago[analyzer] Introduce a simplified API for adding custom path notes.
Artem Dergachev [Fri, 29 Mar 2019 22:21:00 +0000 (22:21 +0000)]
[analyzer] Introduce a simplified API for adding custom path notes.

Almost all path-sensitive checkers need to tell the user when something specific
to that checker happens along the execution path but does not constitute a bug
on its own. For instance, a call to operator delete in C++ has consequences
that are specific to a use-after-free bug. Deleting an object is not a bug
on its own, but when the Analyzer finds an execution path on which a deleted
object is used, it'll have to explain to the user when exactly during that path
did the deallocation take place.

Historically such custom notes were added by implementing "bug report visitors".
These visitors were post-processing bug reports by visiting every ExplodedNode
along the path and emitting path notes whenever they noticed that a change that
is relevant to a bug report occurs within the program state. For example,
it emits a "memory is deallocated" note when it notices that a pointer changes
its state from "allocated" to "deleted".

The "visitor" approach is powerful and efficient but hard to use because
such preprocessing implies that the developer first models the effects
of the event (say, changes the pointer's state from "allocated" to "deleted"
as part of operator delete()'s transfer function) and then forgets what happened
and later tries to reverse-engineer itself and figure out what did it do
by looking at the report.

The proposed approach tries to avoid discarding the information that was
available when the transfer function was evaluated. Instead, it allows the
developer to capture all the necessary information into a closure that
will be automatically invoked later in order to produce the actual note.

This should reduce boilerplate and avoid very painful logic duplication.

On the technical side, the closure is a lambda that's put into a special kind of
a program point tag, and a special bug report visitor visits all nodes in the
report and invokes all note-producing closures it finds along the path.

For now it is up to the lambda to make sure that the note is actually relevant
to the report. For instance, a memory deallocation note would be irrelevant when
we're reporting a division by zero bug or if we're reporting a use-after-free
of a different, unrelated chunk of memory. The lambda can figure these thing out
by looking at the bug report object that's passed into it.

A single checker is refactored to make use of the new functionality: MIGChecker.
Its program state is trivial, making it an easy testing ground for the first
version of the API.

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

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

5 years ago[WebAssembly] Add mutable globals feature
Thomas Lively [Fri, 29 Mar 2019 22:00:18 +0000 (22:00 +0000)]
[WebAssembly] Add mutable globals feature

Summary:
This feature is not actually used for anything in the WebAssembly
backend, but adding it allows users to get it into the target features
sections of their objects, which makes these objects
future-compatible.

Reviewers: aheejin, dschuff

Subscribers: sbc100, jgravelle-google, hiraditya, sunfish, jdoerfert, cfe-commits, llvm-commits

Tags: #clang, #llvm

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

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

5 years ago[Sema] Avoid sending a dependent expression to the constant evaluator.
Erik Pilkington [Fri, 29 Mar 2019 19:53:41 +0000 (19:53 +0000)]
[Sema] Avoid sending a dependent expression to the constant evaluator.

Fixes llvm.org/PR41286

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

5 years ago[Sema] Fix assertion when `auto` parameter in lambda has an attribute.
Volodymyr Sapsai [Fri, 29 Mar 2019 18:47:07 +0000 (18:47 +0000)]
[Sema] Fix assertion when `auto` parameter in lambda has an attribute.

Fixes the assertion
> no Attr* for AttributedType*
> UNREACHABLE executed at llvm-project/clang/lib/Sema/SemaType.cpp:298!

In `TypeProcessingState::getAttributedType` we put into `AttrsForTypes`
types with `auto` but later in
`TypeProcessingState::takeAttrForAttributedType` we use transformed
types and that's why cannot find `Attr` corresponding to
`AttributedType`.

Fix by keeping `AttrsForTypes` up to date after replacing `AutoType`.

rdar://problem/47689465

Reviewers: rsmith, arphaman, aaron.ballman

Reviewed By: aaron.ballman

Subscribers: jkorous, dexonsmith, jdoerfert, cfe-commits

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

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

5 years ago[Driver] Use --warn-shared-textrel for Android.
Dan Albert [Fri, 29 Mar 2019 18:34:25 +0000 (18:34 +0000)]
[Driver] Use --warn-shared-textrel for Android.

Android does not allow shared text relocations. Enable the linker
warning to detect them by default.

Reviewers: srhines, pirama

Reviewed By: srhines

Subscribers: cfe-commits

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

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

5 years agoVarious fixes and additions to creduce-clang-crash.py
George Burgess IV [Fri, 29 Mar 2019 17:50:43 +0000 (17:50 +0000)]
Various fixes and additions to creduce-clang-crash.py

Some more additions to the script - mainly reducing the clang args after
the creduce run by removing them one by one and seeing if the crash
reproduces. Other things:

- remove the --crash flag when "fatal error" occurs
- fixed to read stack trace functions from the top
- run creduce on a copy of the original file

Patch by Amy Huang!

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

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

5 years ago[AMDGPU] Switch default DWARF version to 5
Scott Linder [Fri, 29 Mar 2019 17:45:40 +0000 (17:45 +0000)]
[AMDGPU] Switch default DWARF version to 5

Effectively reverts r337612. The issues that cropped up with the last
attempt appear to have gone away.

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

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

5 years ago[fuchsia] Add clang-doc to Fuchsia distribution
Julie Hockett [Fri, 29 Mar 2019 16:56:37 +0000 (16:56 +0000)]
[fuchsia] Add clang-doc to Fuchsia distribution

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

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

5 years agoclang-cl: Expose -fprofile-generate and -fcs-profile-generate (PR41252)
Hans Wennborg [Fri, 29 Mar 2019 14:03:34 +0000 (14:03 +0000)]
clang-cl: Expose -fprofile-generate and -fcs-profile-generate (PR41252)

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

5 years ago[AArch64] Support selecting TPIDR_EL[1-3] as the thread base
Oliver Stannard [Fri, 29 Mar 2019 13:32:41 +0000 (13:32 +0000)]
[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

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

5 years ago[PowerPC] Add the support for __builtin_setrnd() in clang
Kang Zhang [Fri, 29 Mar 2019 09:11:52 +0000 (09:11 +0000)]
[PowerPC] Add the support for __builtin_setrnd() in clang

Summary:
PowerPC64/PowerPC64le supports the builtin function __builtin_setrnd to set the floating point rounding mode. This function will use the least significant two bits of integer argument to set the floating point rounding mode.
double __builtin_setrnd(int mode);
The effective values for mode are:
0 - round to nearest
1 - round to zero
2 - round to +infinity
3 - round to -infinity
Note that the mode argument will modulo 4, so if the int argument is greater than 3, it will only use the least significant two bits of the mode. Namely, builtin_setrnd(102)) is equal to builtin_setrnd(2).

Reviewed By: jsji

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

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

5 years ago[Sema] Fix a crash when nonnull checking
Michael Liao [Fri, 29 Mar 2019 03:55:52 +0000 (03:55 +0000)]
[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

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

5 years ago[CodeGen][ObjC] Adjust the addresses passed to calls to synthesized
Akira Hatanaka [Fri, 29 Mar 2019 00:23:20 +0000 (00:23 +0000)]
[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

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

5 years agoFix typos and formatting. NFC.
Akira Hatanaka [Fri, 29 Mar 2019 00:23:17 +0000 (00:23 +0000)]
Fix typos and formatting. NFC.

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

5 years ago[MS] Make __iso_volatile_* available on all targets
Reid Kleckner [Thu, 28 Mar 2019 22:59:09 +0000 (22:59 +0000)]
[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.

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

5 years ago[OPENMP]Add check for undefined behavior with thread allocators on
Alexey Bataev [Thu, 28 Mar 2019 19:15:36 +0000 (19:15 +0000)]
[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.

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

5 years ago[Driver] Default Android toolchains to noexecstack.
Dan Albert [Thu, 28 Mar 2019 18:08:28 +0000 (18:08 +0000)]
[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

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

5 years ago[WebAssembly] Reland of rL356953 (4dcf3acce6)
Sam Clegg [Thu, 28 Mar 2019 17:45:18 +0000 (17:45 +0000)]
[WebAssembly] Reland of rL356953 (4dcf3acce6)

The previous patch was missing GetProgramPath() in the return value
of getLinkerPath().

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

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

5 years agoMake helper functions static. NFC.
Benjamin Kramer [Thu, 28 Mar 2019 17:18:42 +0000 (17:18 +0000)]
Make helper functions static. NFC.

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

5 years ago[CodeGen] Add additional mangling for struct members of non trivial structs
Shoaib Meenai [Thu, 28 Mar 2019 17:01:20 +0000 (17:01 +0000)]
[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

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

5 years ago[Analyzer] Constraint Manager - Calculate Effective Range for Differences
Adam Balogh [Thu, 28 Mar 2019 13:05:59 +0000 (13:05 +0000)]
[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

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

5 years agoFix Wdocumentation warning. NFCI.
Simon Pilgrim [Thu, 28 Mar 2019 12:03:49 +0000 (12:03 +0000)]
Fix Wdocumentation warning. NFCI.

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

5 years ago[PR41247] Fixed parsing of private keyword in C++.
Anastasia Stulova [Thu, 28 Mar 2019 11:47:14 +0000 (11:47 +0000)]
[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

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

5 years agoFix tests after rC357150
Fangrui Song [Thu, 28 Mar 2019 08:41:17 +0000 (08:41 +0000)]
Fix tests after rC357150

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

5 years ago[Driver] Allow -gsplit-dwarf on ELF OSes other than Linux and Fuchsia
Fangrui Song [Thu, 28 Mar 2019 08:24:00 +0000 (08:24 +0000)]
[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.

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

5 years agoRevert "[WebAssembly] Don't use default GetLinkerPath"
Derek Schuff [Wed, 27 Mar 2019 22:22:18 +0000 (22:22 +0000)]
Revert "[WebAssembly] Don't use default GetLinkerPath"

This reverts commit 4dcf3acce6d7455fd079d8e57441906ca2bad254.
(reverts LLVM SVN r356953)

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

5 years ago[ASTImporter] Fix IsStructuralMatch specialization for EnumDecl to prevent re-importi...
Shafik Yaghmour [Wed, 27 Mar 2019 17:47:36 +0000 (17:47 +0000)]
[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

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

5 years ago[OPENMP]Initial support for 'allocate' clause.
Alexey Bataev [Wed, 27 Mar 2019 14:14:31 +0000 (14:14 +0000)]
[OPENMP]Initial support for 'allocate' clause.

Added parsing/sema analysis of the allocate clause.

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

5 years agoRevert the r348352 "[clang] - Simplify tools::SplitDebugName."
George Rimar [Wed, 27 Mar 2019 11:00:03 +0000 (11:00 +0000)]
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.

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

5 years agoEmit -Wfortify-source using DiagRuntimeBehaviour
Erik Pilkington [Tue, 26 Mar 2019 23:21:22 +0000 (23:21 +0000)]
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));

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

5 years ago[Sema] Fix an assert when a block captures a constexpr local
Erik Pilkington [Tue, 26 Mar 2019 23:21:19 +0000 (23:21 +0000)]
[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

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

5 years agoBasic: Return a reference from FileManager::getVirtualFileSystem, NFC
Duncan P. N. Exon Smith [Tue, 26 Mar 2019 22:32:06 +0000 (22:32 +0000)]
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

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

5 years agoFrontend: Remove CompilerInstance::VirtualFileSystem, NFC
Duncan P. N. Exon Smith [Tue, 26 Mar 2019 22:18:52 +0000 (22:18 +0000)]
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

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

5 years ago[cmake] Reset variable before using it
Shoaib Meenai [Tue, 26 Mar 2019 22:16:53 +0000 (22:16 +0000)]
[cmake] Reset variable before using it

A bunch of macros use the same variable name, and since CMake macros
don't get their own scope, the value persists across macro invocations,
and we can end up exporting targets which shouldn't be exported. Clear
the variable before each use to avoid this.

Converting these macros to functions would also help, since it would
avoid the variable leaking into its parent scope, and that's something I
plan to follow up with. It won't fully address the problem, however,
since functions still inherit variables from their parent scopes, so if
someone in the parent scope just happened to use the same variable name
we'd still have the same issue.

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

5 years agoMake -mno-outline pass -enable-machine-outliner=never to ld in LTO
Jessica Paquette [Tue, 26 Mar 2019 21:22:42 +0000 (21:22 +0000)]
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.

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

5 years ago[clang-format] Add style option AllowShortLambdasOnASingleLine
Ronald Wampler [Tue, 26 Mar 2019 20:18:14 +0000 (20:18 +0000)]
[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

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

5 years ago[CodeGen] Delete never used LValueAlign
Fangrui Song [Tue, 26 Mar 2019 15:39:45 +0000 (15:39 +0000)]
[CodeGen] Delete never used LValueAlign

It was added by rC176658 but never used since then.

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

5 years ago[OpenCL] Allow variadic macros as Clang feature.
Anastasia Stulova [Tue, 26 Mar 2019 11:22:37 +0000 (11:22 +0000)]
[OpenCL] Allow variadic macros as Clang feature.

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

5 years agoupdate the release notes after the change of 'clang -dumpversion'
Sylvestre Ledru [Tue, 26 Mar 2019 09:48:23 +0000 (09:48 +0000)]
update the release notes after the change of 'clang -dumpversion'

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

5 years ago[RISCV] Pass -target-abi to -cc1as
Roger Ferrer Ibanez [Tue, 26 Mar 2019 08:01:18 +0000 (08:01 +0000)]
[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

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

5 years ago[CMake][Fuchsia] Merge static libunwind and libc++abi into libc++ on Darwin
Petr Hosek [Tue, 26 Mar 2019 00:43:29 +0000 (00:43 +0000)]
[CMake][Fuchsia] Merge static libunwind and libc++abi into libc++ on Darwin

We want to distribute only a single archive so -lc++ does the right
thing and users don't have to explicitly link -lc++abi and -lunwind.

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

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

5 years ago[CFG] [analyzer] pr41142: C++17: Skip transparent InitListExprs in ExprEngine.
Artem Dergachev [Tue, 26 Mar 2019 00:36:53 +0000 (00:36 +0000)]
[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

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

5 years ago[MS] Add frontend support for __declspec(allocator)
Reid Kleckner [Mon, 25 Mar 2019 23:20:18 +0000 (23:20 +0000)]
[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

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

5 years ago[Sema] Don't check for array bounds when the types in the base expression are dependent
Bruno Ricci [Mon, 25 Mar 2019 21:37:10 +0000 (21:37 +0000)]
[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

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

5 years ago[WebAssembly] Don't use default GetLinkerPath
Sam Clegg [Mon, 25 Mar 2019 21:14:26 +0000 (21:14 +0000)]
[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

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

5 years agoAMDGPU: Add support for cross address space synchronization scopes (clang)
Konstantin Zhuravlyov [Mon, 25 Mar 2019 20:54:00 +0000 (20:54 +0000)]
AMDGPU: Add support for cross address space synchronization scopes (clang)

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

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

5 years agoThread Safety: also look at ObjC methods
JF Bastien [Mon, 25 Mar 2019 20:06:32 +0000 (20:06 +0000)]
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

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

5 years agoclang -dumpversion returns 4.2.1 for legacy reason, update it
Sylvestre Ledru [Mon, 25 Mar 2019 18:06:20 +0000 (18:06 +0000)]
clang -dumpversion returns 4.2.1 for legacy reason, update it

Summary:
It has been introduced in 2011 for gcc compat:
https://github.com/llvm-mirror/clang/commit/95a907fc0f2f717dca38a379c1d2353bfea06d4f
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

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

5 years agoMoved everything SMT-related to LLVM and updated the cmake scripts.
Mikhail R. Gadelha [Mon, 25 Mar 2019 17:47:45 +0000 (17:47 +0000)]
Moved everything SMT-related to LLVM and updated the cmake scripts.

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

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

5 years ago[clang-format] Refine structured binding detection
Krasimir Georgiev [Mon, 25 Mar 2019 17:29:16 +0000 (17:29 +0000)]
[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

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

5 years ago[Sema][NFCI] Don't allocate storage for the various CorrectionCandidateCallback unles...
Bruno Ricci [Mon, 25 Mar 2019 17:08:51 +0000 (17:08 +0000)]
[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

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

5 years ago[clang] Remove cmake warning message (NFC)
Evandro Menezes [Mon, 25 Mar 2019 16:38:48 +0000 (16:38 +0000)]
[clang] Remove cmake warning message (NFC)

Recognize an empty string for CLANG_DEFAULT_UNWINDLIB as a valid option.

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

5 years agoRevert "[clang-format] Keep protobuf "package" statement on one line"
Haojian Wu [Mon, 25 Mar 2019 15:46:07 +0000 (15:46 +0000)]
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");

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

5 years ago[OpenCL] Allow addr space spelling without __ prefix in C++.
Anastasia Stulova [Mon, 25 Mar 2019 11:54:02 +0000 (11:54 +0000)]
[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

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

5 years ago[ASTImporter] Changed use of Import to Import_New in ASTNodeImporter.
Balazs Keri [Mon, 25 Mar 2019 09:16:39 +0000 (09:16 +0000)]
[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

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

5 years agoUn-revert "[coroutines][PR40978] Emit error for co_yield within catch block"
Brian Gesiak [Mon, 25 Mar 2019 00:53:10 +0000 (00:53 +0000)]
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

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

5 years ago[X86] Make _bswap intrinsic a function instead of a macro to hopefully fix the chromi...
Craig Topper [Sun, 24 Mar 2019 18:00:20 +0000 (18:00 +0000)]
[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.

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

5 years ago[X86] Add BSR/BSF/BSWAP intrinsics to ia32intrin.h to match gcc.
Craig Topper [Sun, 24 Mar 2019 00:56:52 +0000 (00:56 +0000)]
[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

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

5 years ago[WebAssembly] Fix test/Driver/wasm-toolchain.c in the presence of CLANG_DEFAULT_LINKER
Sam Clegg [Sun, 24 Mar 2019 00:03:41 +0000 (00:03 +0000)]
[WebAssembly] Fix test/Driver/wasm-toolchain.c in the presence of CLANG_DEFAULT_LINKER

This was broken in rL356817 (See https://reviews.llvm.org/D59721)

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

5 years agolibclang/CIndexer.cpp: Use loadquery() on AIX for path to library
Hubert Tong [Sat, 23 Mar 2019 18:10:45 +0000 (18:10 +0000)]
libclang/CIndexer.cpp: Use loadquery() on AIX for path to library

Summary:
`dladdr` is not available on AIX. Similar functionality is presented
through `loadquery`. This patch replaces a use of `dladdr` with a
version based on `loadquery`.

Reviewers: sfertile, xingxue, jasonliu

Reviewed By: xingxue

Subscribers: jsji, lhames, majnemer, asb, arphaman, cfe-commits

Tags: #clang

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

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

5 years agoSync some doc changes ClangFormatStyleOptions.rst with doc comments in `Format.h`
Sylvestre Ledru [Sat, 23 Mar 2019 17:57:31 +0000 (17:57 +0000)]
Sync some doc changes ClangFormatStyleOptions.rst with doc comments in `Format.h`

Summary:
These changes were corrected directly in ClangFormatStyleOptions.rst (llvm-svn: 350192 and llvm-svn: 351976) but these sections can be produced automatically using `dump_format_style.py` so sync the corresponding doc comments in `Format.h` as well.

Patch by Ronald Wampler

Reviewers: eugene, sylvestre.ledru, djasper

Reviewed By: sylvestre.ledru

Subscribers: jdoerfert, cfe-commits

Tags: #clang

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

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

5 years agoFix unused variable warning. NFCI.
Simon Pilgrim [Sat, 23 Mar 2019 16:16:46 +0000 (16:16 +0000)]
Fix unused variable warning. NFCI.

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

5 years ago[clang-format] Keep protobuf "package" statement on one line
Paul Hoad [Sat, 23 Mar 2019 14:43:41 +0000 (14:43 +0000)]
[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)

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

5 years agoClang-format: add finer-grained options for putting all arguments on one line
Paul Hoad [Sat, 23 Mar 2019 14:37:58 +0000 (14:37 +0000)]
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)

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

5 years ago[clang-format] correctly format protobuf fields named "enum".
Paul Hoad [Sat, 23 Mar 2019 14:24:30 +0000 (14:24 +0000)]
[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)

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

5 years agoIRGen: Remove StructorType; thread GlobalDecl through more code. NFCI.
Peter Collingbourne [Fri, 22 Mar 2019 23:05:10 +0000 (23:05 +0000)]
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

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

5 years ago[clang-format][NFC] correct the release notes
Paul Hoad [Fri, 22 Mar 2019 22:47:34 +0000 (22:47 +0000)]
[clang-format][NFC] correct the release notes

Move the clang-format notes to the correct section

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

5 years ago[WebAssembly] Make driver -pthread imply linker --shared-memory
Thomas Lively [Fri, 22 Mar 2019 22:25:37 +0000 (22:25 +0000)]
[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

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

5 years ago[clang] Add support for Exynos M5 (NFC)
Evandro Menezes [Fri, 22 Mar 2019 18:44:09 +0000 (18:44 +0000)]
[clang] Add support for Exynos M5 (NFC)

Add Exynos M5 test cases.

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

5 years agoIR: Support parsing numeric block ids, and emit them in textual output.
James Y Knight [Fri, 22 Mar 2019 18:27:13 +0000 (18:27 +0000)]
IR: Support parsing numeric block ids, and emit them in textual output.

Just as as llvm IR supports explicitly specifying numeric value ids
for instructions, and emits them by default in textual output, now do
the same for blocks.

This is a slightly incompatible change in the textual IR format.

Previously, llvm would parse numeric labels as string names. E.g.
  define void @f() {
    br label %"55"
  55:
    ret void
  }
defined a label *named* "55", even without needing to be quoted, while
the reference required quoting. Now, if you intend a block label which
looks like a value number to be a name, you must quote it in the
definition too (e.g. `"55":`).

Previously, llvm would print nameless blocks only as a comment, and
would omit it if there was no predecessor. This could cause confusion
for readers of the IR, just as unnamed instructions did prior to the
addition of "%5 = " syntax, back in 2008 (PR2480).

Now, it will always print a label for an unnamed block, with the
exception of the entry block. (IMO it may be better to print it for
the entry-block as well. However, that requires updating many more
tests.)

Thus, the following is supported, and is the canonical printing:
  define i32 @f(i32, i32) {
    %3 = add i32 %0, %1
    br label %4

  4:
    ret i32 %3
  }

New test cases covering this behavior are added, and other tests
updated as required.

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

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

5 years ago[ARM] Fix bug 39982 - pcs("aapcs-vfp") is not consistent
Carey Williams [Fri, 22 Mar 2019 16:20:45 +0000 (16:20 +0000)]
[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

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

5 years agoRevert "[coroutines][PR40978] Emit error for co_yield within catch block"
Brian Gesiak [Fri, 22 Mar 2019 16:08:29 +0000 (16:08 +0000)]
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.

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

5 years ago[OPENMP]Add missing comment, NFC.
Alexey Bataev [Fri, 22 Mar 2019 15:32:02 +0000 (15:32 +0000)]
[OPENMP]Add missing comment, NFC.

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

5 years ago[OPENMP]Allow no allocator clause in target regions with requires
Alexey Bataev [Fri, 22 Mar 2019 15:25:12 +0000 (15:25 +0000)]
[OPENMP]Allow no allocator clause in target regions with requires
dynamic_allocators.

According to the OpenMP 5.0, 2.11.3 allocate Directive, Restrictions,
allocate directives that appear in a target region must specify an
allocator clause unless a requires directive with the dynamic_allocators
clause is present in the same compilation unit. Patch adds a check for a
presence of the requires directive with the dynamic_allocators clause.

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

5 years ago[OPENMP]Emit error message for allocate directive without allocator
Alexey Bataev [Fri, 22 Mar 2019 14:41:39 +0000 (14:41 +0000)]
[OPENMP]Emit error message for allocate directive without allocator
clause in target region.

According to the OpenMP 5.0, 2.11.3 allocate Directive, Restrictions,
allocate directives that appear in a target region must specify an
allocator clause unless a requires directive with the dynamic_allocators
clause is present in the same compilation unit.

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

5 years ago[AST] OMPStructuredBlockTest: avoid using multiline string literals in macros
Roman Lebedev [Fri, 22 Mar 2019 13:40:36 +0000 (13:40 +0000)]
[AST] OMPStructuredBlockTest: avoid using multiline string literals in macros

That is what i have been doing elsewhere in these tests, maybe that's it?

Maybe this helps with failing builds:
http://lab.llvm.org:8011/builders/clang-cmake-aarch64-quick/builds/17921
http://lab.llvm.org:8011/builders/clang-cmake-aarch64-global-isel/builds/10248

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

5 years ago[Tooling] Avoid working-dir races in AllTUsToolExecutor
Ilya Biryukov [Fri, 22 Mar 2019 11:01:13 +0000 (11:01 +0000)]
[Tooling] Avoid working-dir races in AllTUsToolExecutor

Reviewers: ioeric

Reviewed By: ioeric

Subscribers: jdoerfert, cfe-commits

Tags: #clang

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

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

5 years ago[ARM] Add Cortex-M35P Support
Luke Cheeseman [Fri, 22 Mar 2019 10:58:15 +0000 (10:58 +0000)]
[ARM] Add Cortex-M35P Support

- Add clang frontend testing for Cortex-M35P

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

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

5 years agoThis test assumes that -rtlib defaults to libgcc. But that isn't true in the face...
Sterling Augustine [Thu, 21 Mar 2019 23:30:50 +0000 (23:30 +0000)]
This test assumes that -rtlib defaults to libgcc. But that isn't true in the face of -DCLANG_DEFAULT_RTLIB=compiler-rt.

Subscribers: dberris, jdoerfert, llvm-commits

Tags: #llvm

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

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

5 years ago[AArch64] Split the neon.addp intrinsic into integer and fp variants.
Amara Emerson [Thu, 21 Mar 2019 22:31:37 +0000 (22:31 +0000)]
[AArch64] Split the neon.addp intrinsic into integer and fp variants.

This is the result of discussions on the list about how to deal with intrinsics
which require codegen to disambiguate them via only the integer/fp overloads.
It causes problems for GlobalISel as some of that information is lost during
translation, while with other operations like IR instructions the information is
encoded into the instruction opcode.

This patch changes clang to emit the new faddp intrinsic if the vector operands
to the builtin have FP element types. LLVM IR AutoUpgrade has been taught to
upgrade existing calls to aarch64.neon.addp with fp vector arguments, and
we remove the workarounds introduced for GlobalISel in r355865.

This is a more permanent solution to PR40968.

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

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

5 years ago[OPENMP]Fix a warning about unused variable, NFC.
Alexey Bataev [Thu, 21 Mar 2019 20:52:04 +0000 (20:52 +0000)]
[OPENMP]Fix a warning about unused variable, NFC.

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

5 years agoImprove the diagnostic for #include_next occurring in a file not found
Richard Smith [Thu, 21 Mar 2019 20:42:13 +0000 (20:42 +0000)]
Improve the diagnostic for #include_next occurring in a file not found
in the include path.

Instead of making the incorrect claim that the included file has an
absolute path, describe the actual problem: the including file was found
either by absolute path, or relative to such a file, or relative to the
primary source file.

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

5 years ago[OPENMP] Simplify codegen for allocate directive on local variables.
Alexey Bataev [Thu, 21 Mar 2019 20:36:16 +0000 (20:36 +0000)]
[OPENMP] Simplify codegen for allocate directive on local variables.

Simplified codegen for the allocate directive for local variables,
initial implementation of the codegen for NVPTX target.

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

5 years ago[X86] Correct the value of MaxAtomicInlineWidth for pre-586 cpus
Craig Topper [Thu, 21 Mar 2019 20:36:08 +0000 (20:36 +0000)]
[X86] Correct the value of MaxAtomicInlineWidth for pre-586 cpus

Use the new cx8 feature flag that was added to the backend to represent support for cmpxchg8b. Use this flag to set the MaxAtomicInlineWidth.

This also assumes all the cmpxchg instructions are enabled for CK_Generic which is what cc1 defaults to when nothing is specified.

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

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

5 years ago[Driver] Pass -malign-double from the driver to the cc1 command line
Craig Topper [Thu, 21 Mar 2019 20:07:24 +0000 (20:07 +0000)]
[Driver] Pass -malign-double from the driver to the cc1 command line

-malign-double is currently only implemented in the -cc1 interface. But its declared in Options.td so it is a driver option too. But you try to use it with the driver you'll get a message about the option being unused.

This patch teaches the driver to pass the option through to cc1 so it won't be unused. The Options.td says the option is x86 only but I didn't see any x86 specific code in its impementation in cc1 so not sure if the documentation is wrong or if I should only pass this option through the driver on x86 targets.

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

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

5 years ago[CodeGen][ObjC] Annotate calls to objc_retainAutoreleasedReturnValue
Akira Hatanaka [Thu, 21 Mar 2019 19:59:49 +0000 (19:59 +0000)]
[CodeGen][ObjC] Annotate calls to objc_retainAutoreleasedReturnValue
with notail on x86-64.

On x86-64, the epilogue code inserted before the tail jump blocks the
autoreleased return optimization.

rdar://problem/38675807

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

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

5 years agoRefactor handling of #include directives to cleanly separate the
Richard Smith [Thu, 21 Mar 2019 19:44:17 +0000 (19:44 +0000)]
Refactor handling of #include directives to cleanly separate the
"skipped header because it should be imported as a module" cases from
the "skipped header because of some other reason" cases.

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

5 years ago[OPENMP]Codegen support for allocate directive on global variables.
Alexey Bataev [Thu, 21 Mar 2019 19:35:27 +0000 (19:35 +0000)]
[OPENMP]Codegen support for allocate directive on global variables.

For the global variables the allocate directive must specify only the
predefined allocator. This allocator must be translated into the correct
form of the address space for the targets that support different address
spaces.

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

5 years ago[clang][OpenMP] Fix another test when using libgomp.
Jordan Rupprecht [Thu, 21 Mar 2019 19:13:22 +0000 (19:13 +0000)]
[clang][OpenMP] Fix another test when using libgomp.

Similarly to r356614, -fopenmp=libomp needs to be used for some omp-related AST matching.

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

5 years ago[OPENMP]Simplify the check for the predefined allocators, NFC.
Alexey Bataev [Thu, 21 Mar 2019 19:05:07 +0000 (19:05 +0000)]
[OPENMP]Simplify the check for the predefined allocators, NFC.

Previously implemented check required the reevaluation of the already
evaluated predefined allocator kind for the global variables. Patch
simplifies this evaluation and removes extra code.

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

5 years ago[X86] Add __popcntd and __popcntq to ia32intrin.h to match gcc and icc. Remove popcnt...
Craig Topper [Thu, 21 Mar 2019 17:43:53 +0000 (17:43 +0000)]
[X86] Add __popcntd and __popcntq to ia32intrin.h to match gcc and icc. Remove popcnt feature flag from _popcnt32/_popcnt64 and move to ia32intrin.h to match gcc

gcc and icc both implement popcntd and popcntq which we did not. gcc doesn't seem to require a feature flag for the _popcnt32/_popcnt64 spelling and will use a libcall if its not supported.

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

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

5 years ago[X86] Use the CPUKind enum from PROC_ALIAS to directly get the CPUKind in fillValidCP...
Craig Topper [Thu, 21 Mar 2019 17:33:20 +0000 (17:33 +0000)]
[X86] Use the CPUKind enum from PROC_ALIAS to directly get the CPUKind in fillValidCPUList.

We were using getCPUKind which translates the string to the enum also using PROC_ALIAS. This just cuts out the string compares.

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

5 years ago[AST] OMPStructuredBlockTest: two matchers were promoted into ASTMatchers.h
Roman Lebedev [Thu, 21 Mar 2019 15:50:54 +0000 (15:50 +0000)]
[AST] OMPStructuredBlockTest: two matchers were promoted into ASTMatchers.h

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

5 years ago[ASTMatcher] Add clang-query disclaimer to two more matchers that take enum
Roman Lebedev [Thu, 21 Mar 2019 15:33:43 +0000 (15:33 +0000)]
[ASTMatcher] Add clang-query disclaimer to two more matchers that take enum

As we have figured out in
https://reviews.llvm.org/D57112
and
https://bugs.llvm.org/show_bug.cgi?id=41176

this kind-of works, but needs special care.

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

5 years ago[ASTMatchers][OpenMP] OpenMP Structured-block-related matchers
Roman Lebedev [Thu, 21 Mar 2019 15:33:35 +0000 (15:33 +0000)]
[ASTMatchers][OpenMP] OpenMP Structured-block-related matchers

Summary: Exposes to the  for ASTMatchers the interface/modelling
of OpenMP structured-block.

Reviewers: gribozavr, aaron.ballman, JonasToth, george.karpenkov

Reviewed By: gribozavr, aaron.ballman

Subscribers: guansong, jdoerfert, cfe-commits

Tags: #clang, #openmp

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

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

5 years ago[ASTTypeTraits][ASTMatchers][OpenMP] OMPClause handling
Roman Lebedev [Thu, 21 Mar 2019 15:33:24 +0000 (15:33 +0000)]
[ASTTypeTraits][ASTMatchers][OpenMP] OMPClause handling

Summary:
`OMPClause` is the base class, it is not descendant from **any**
other class, therefore for it to work with e.g.
`VariadicDynCastAllOfMatcher<>`, it needs to be handled here.

Reviewers: sbenza, bkramer, pcc, klimek, hokein, gribozavr, aaron.ballman, george.karpenkov

Reviewed By: gribozavr, aaron.ballman

Subscribers: guansong, jdoerfert, alexfh, ABataev, cfe-commits

Tags: #openmp, #clang

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

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