Commit Graph

70514 Commits

Author SHA1 Message Date
Sean Callanan 967d438439 Add support for remembering origins to ExternalASTMerger
ExternalASTMerger has hitherto relied on being able to look up 
any Decl through its named DeclContext chain. This works for 
many cases, but causes problems for function-local structs, 
which cannot be looked up in their containing FunctionDecl. An
example case is

void f() {
  { struct S { int a; }; }
  { struct S { bool b; }; }
}

It is not possible to lookup either of the two Ses individually 
(or even to provide enough information to disambiguate) after 
parsing is over; and there is typically no need to, since they 
are invisible to the outside world.

However, ExternalASTMerger needs to be able to complete either 
S on demand. This led to an XFAIL on test/Import/local-struct, 
which this patch removes. The way the patch works is:

It defines a new data structure, ExternalASTMerger::OriginMap,
which clients are expected to maintain (default-constructing 
if the origin does not have an ExternalASTMerger servicing it)
As DeclContexts are imported, if they cannot be looked up by 
name they are placed in the OriginMap. This allows 
ExternalASTMerger to complete them later if necessary.
As DeclContexts are imported from an origin that already has 
its own OriginMap, the origins are forwarded – but only for 
those DeclContexts that are actually used. This keeps the 
amount of stored data minimal.

The patch also applies several improvements from review:

- Thoroughly documents the interface to ExternalASTMerger;
- Adds optional logging to help track what's going on; and
- Cleans up a bunch of braces and dangling elses.

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

llvm-svn: 314336
2017-09-27 19:57:58 +00:00
Artem Belevich 93e33f8fb3 [CUDA] Work around conflicting function definitions in CUDA-9 headers.
Differential Revision: https://reviews.llvm.org/D38326

llvm-svn: 314334
2017-09-27 19:07:15 +00:00
Jonas Hahnfeld 102c333d9a [OpenMP] Fix translation of target args
ToolChain::TranslateArgs() returns nullptr if no changes are performed.
This would currently mean that OpenMPArgs are lost. Patch fixes this
by falling back to simply using OpenMPArgs in that case.

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

llvm-svn: 314330
2017-09-27 18:12:36 +00:00
Jonas Hahnfeld 757e61fa4f [OpenMP] Fix passing of -m arguments to device toolchain
AuxTriple is not set if host and device share a toolchain. Also,
removing an argument modifies the DAL which needs to be returned
for future use.
(Move tests back to offload-openmp.c as they are not related to GPUs.)

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

llvm-svn: 314329
2017-09-27 18:12:34 +00:00
Jonas Hahnfeld 85f19958e9 [OpenMP] Fix memory leak when translating arguments
Parsing the argument after -Xopenmp-target allocates memory that needs
to be freed. Associate it with the final DerivedArgList after we know
which one will be used.

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

llvm-svn: 314328
2017-09-27 18:12:31 +00:00
Nico Weber b9b1867519 clang-format/java: Unbreak genenrics formatting after r299952.
https://reviews.llvm.org/rL299952 merged '>>>' tokens into a single
JavaRightLogicalShift token. This broke formatting of generics nested more than
two deep, e.g. Foo<Bar<Baz>>> because the '>>>' now weren't three '>' for
parseAngle().

Luckily, just deleting JavaRightLogicalShift fixes things without breaking the
test added in r299952, so do that.

https://reviews.llvm.org/D38291

llvm-svn: 314325
2017-09-27 17:57:50 +00:00
Anastasia Stulova 89a947da72 [OpenCL] Fixed CL version in failing test.
llvm-svn: 314317
2017-09-27 17:03:35 +00:00
Anastasia Stulova 0a72ed40d3 [OpenCL] Handle address space conversion while setting type alignment.
Added missing addrspacecast case in alignment computation
logic of pointer type emission in IR generation.

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

llvm-svn: 314304
2017-09-27 14:37:00 +00:00
Gheorghe-Teodor Bercea 965c7e9c6e [OpenMP] Add an additional test for D34888
Summary: Test for checking if the mapping is performed correctly. This is a test initially included in Patch https://reviews.llvm.org/D29905

Reviewers: Hahnfeld, carlo.bertolli, caomhin, ABataev

Reviewed By: Hahnfeld

Subscribers: tra, cfe-commits

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

llvm-svn: 314303
2017-09-27 14:31:08 +00:00
Coby Tayree d5e7410dca revert rL314300
accidently added only tests w/o the respective changes..

llvm-svn: 314302
2017-09-27 13:02:44 +00:00
Coby Tayree 0b1ed7e19a [X86][MS-InlineAsm] Extended support for variables / identifiers on memory / immediate expressions
Allow the proper recognition of Enum values and global variables inside ms inline-asm memory / immediate expressions, as they require some additional overhead and treated incorrect if doesn't early recognized.
supersedes D33277, D35775
Corrsponds with D37412, D37413

llvm-svn: 314300
2017-09-27 12:36:54 +00:00
Artem Dergachev d85a994ca6 [analyzer] Fix an outdated comment in a test. NFC.
llvm-svn: 314298
2017-09-27 10:59:06 +00:00
Artem Dergachev 8c80061535 [analyzer] Match more patterns in bugreporter::getDerefExpr() API.
This function can now track null pointer through simple pointer arithmetic,
such as '*&*(p + 2)' => 'p' and so on, displaying intermediate diagnostic pieces
for the user to understand where the null pointer is coming from.

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

llvm-svn: 314290
2017-09-27 09:50:45 +00:00
Artem Dergachev 2064e82277 [analyzer] Fix and refactor bugreporter::getDerefExpr() API.
This API is used by checkers (and other entities) in order to track where does
a value originate from, by jumping from an expression value of which is equal
to that value to the expression from which this value has "appeared". For
example, it may be an lvalue from which the rvalue was loaded, or a function
call from which the dereferenced pointer was returned.

The function now avoids incorrectly unwrapping implicit lvalue-to-rvalue casts,
which caused crashes and incorrect intermediate diagnostic pieces. It also no
longer relies on how the expression is written when guessing what it means.

Fixes pr34373 and pr34731.

rdar://problem/33594502

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

llvm-svn: 314287
2017-09-27 09:33:37 +00:00
Marek Kurdej caf6fd51ee [clang-format] Fix FixNamespaceComments when BraceWrapping AfterNamespace is true.
Summary:
NamespaceEndCommentsFixer did not fix namespace comments when the brace opening the namespace was not on the same line as the "namespace" keyword.
It occurs in Allman, GNU and Linux styles and whenever BraceWrapping.AfterNamespace is true.

Before:
```lang=cpp
    namespace a
    {
    void f();
    void g();
    }
```

After:
```lang=cpp
    namespace a
    {
    void f();
    void g();
    } // namespace a
```

Reviewers: krasimir

Reviewed By: krasimir

Subscribers: klimek, cfe-commits

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

llvm-svn: 314279
2017-09-27 07:51:51 +00:00
Erich Keane 015ccd0822 Add test forgotten in r314262.
llvm-svn: 314268
2017-09-27 03:23:02 +00:00
Erich Keane b11ebc5e3d Fix capitalization of a bunch of parameters in SemaDeclAttr [NFC]
llvm-svn: 314267
2017-09-27 03:20:13 +00:00
Chih-Hung Hsieh 30cd301112 [clang-format] Adjust space around &/&& of structured bindings
Keep space before or after the &/&& tokens, but not both. For example,
  auto [x,y] = a;
  auto &[xr, yr] = a; // LLVM style
  auto& [xr, yr] = a; // google style

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

llvm-svn: 314264
2017-09-27 00:58:45 +00:00
Erich Keane 99fdfb6a46 Emit section information for extern variables.
Currently, if _attribute_((section())) is used for extern variables, 
section information is not emitted in generated IR when the variables are used. 
This is expected since sections are not generated for external linkage objects. 
However NiosII requires this information as it uses special GP-relative accesses 
for any objects that use attribute section (.sdata). GCC keeps this attribute in 
  middle-end.

This change emits the section information for all targets.

Patch By: Elizabeth Andrews

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

llvm-svn: 314262
2017-09-26 23:42:34 +00:00
Richard Smith fd54435b95 Fix uninitialized member found by msan build bot.
llvm-svn: 314246
2017-09-26 21:33:43 +00:00
Saleem Abdulrasool 3450aa7257 Sema: rename SemaBuiltinVAStart to SemaBuiltinVAStartMicrosoft
This function is used to perform semantic analysis on Microsoft style
`__va_start`.  Rename it to make this more explicit.  `__va_start` is
marked as `ALL_MS_LANGUAGES`, and requires Microsoft compatibility.
Other GNU targets will use `__builtin_va_start` instead.  NFC.

Addresses post-commit review comments from David Majnemer.

llvm-svn: 314241
2017-09-26 20:12:04 +00:00
Gheorghe-Teodor Bercea db6decd456 Revert commmit 314228.
llvm-svn: 314240
2017-09-26 19:58:23 +00:00
Saleem Abdulrasool 4d321336d0 Basic: support Preserve{Most,All} CC on Windows
Add support for the `preserve_mostcc` and `preserve_allcc` on Windows
x86_64 and AArch64.  This is used by Swift.

llvm-svn: 314236
2017-09-26 19:26:01 +00:00
Erich Keane 99eda60b49 Allow IUnknown/IInterface types to come from extern C++
It was brought up in response to my last implementation for
this struct-as-interface features that at least 1 header in
the MS SDK uses "extern C++" around an IUnknown declaration.

The previous implementation demanded that this type exist
in the TranslationUnit DeclContext.  This small change simply
also allows in the situation where we're extern "C++".

llvm-svn: 314235
2017-09-26 18:55:16 +00:00
Nico Weber dffc55c1cd Delete trailing whitespace.
llvm-svn: 314232
2017-09-26 18:38:56 +00:00
Richard Smith 67ef14fe48 Resolve a defect in C++17 copy omission.
When selecting constructors for initializing an object of type T from a single
expression of class type U, also consider conversion functions of U that
convert to T (rather than modeling such conversions as calling a conversion
function and then calling a constructor).

This approach is proposed as the resolution for the defect, and is also already
implemented by GCC.

llvm-svn: 314231
2017-09-26 18:37:55 +00:00
Erich Keane 9d10bdf644 [Sema] Corrected the warn-on-throw-from-noexcept behavior to include nothrow
Discovered that 'nothrow' (which is supposed to be an alias for noexcept)
was not warning with a throw inside of it. This patch corrects the behavior
previously created to add 'nothrow' to this list.

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

llvm-svn: 314229
2017-09-26 18:20:39 +00:00
Gheorghe-Teodor Bercea b379ba6a62 [OpenMP] Add an additional test for D34888
Summary: Test for checking if the mapping is performed correctly. This is a test initially included in Patch https://reviews.llvm.org/D29905

Reviewers: Hahnfeld, carlo.bertolli, caomhin

Reviewed By: Hahnfeld

Subscribers: tra, cfe-commits

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

llvm-svn: 314228
2017-09-26 18:12:12 +00:00
Saleem Abdulrasool 448e8ad943 Sema: Windows/ARM __va_start is not const correct
The `__va_start` intrinsic for Windows ARM does not account for const
correctness when performing a check.  All local qualifiers are ignored
when validating the invocation.  This was exposed by building the swift
stdlib against the Windows 10586 SDK for ARM.  Simply expand out the
check for the two parameters and ignore the qualifiers for the check.

llvm-svn: 314226
2017-09-26 17:44:10 +00:00
Artem Belevich bab95c7087 [NVPTX] added match.{any,all}.sync instructions, intrinsics & builtins.
Differential Revision: https://reviews.llvm.org/D38191

llvm-svn: 314223
2017-09-26 17:07:23 +00:00
Alexey Bataev 5ec3893b3a [OPENMP] Fix handling of implicit mapping of array sections.
llvm-svn: 314220
2017-09-26 16:19:04 +00:00
Artem Dergachev 4388ffa91d [analyzer] Keep track of design discusions as part of analyzer documentation.
Create a directory to store discussions on potentially useful features that are
not yet implemented in the analyzer.

Fill it with a discussion on representing checker-specific parts of the program
state for C++ object modeling, that occured in D35216.

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

llvm-svn: 314218
2017-09-26 15:49:53 +00:00
Gheorghe-Teodor Bercea 5a3608ccfa [OpenMP] Don't throw cudalib not found error if only front-end is required.
Summary: If we only use the compiler front-end, do not throw an error about the cuda device library not being found. This allows the front-end to be run on systems where no Cuda installation is found.

Reviewers: Hahnfeld, ABataev, carlo.bertolli, caomhin, tra

Reviewed By: tra

Subscribers: hfinkel, tra, cfe-commits

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

llvm-svn: 314217
2017-09-26 15:36:20 +00:00
Gheorghe-Teodor Bercea 1f29745315 Revert commit 314210.
llvm-svn: 314215
2017-09-26 15:24:34 +00:00
Simon Dardis ef41f6a573 [mips] Accept but ignore -m(no-)branch-likely
-mbranch-likely and -mno-branch-likely are used in some build systems for
some MIPS targets. Accept these options but ignore them as they are an
(de)optimiztion hint, and that branch likely instructions were deprecated
but not removed from MIPS32 and MIPS64 ISAs.

Reviewers: atanasyan, nitesh.jain

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

llvm-svn: 314213
2017-09-26 15:01:21 +00:00
Krasimir Georgiev a84e78700f [clang-format] Add ext/ to google include categories
Summary: This adds an ext/ header include category for google style.

Reviewers: djasper

Reviewed By: djasper

Subscribers: cfe-commits, klimek

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

llvm-svn: 314211
2017-09-26 14:58:29 +00:00
Gheorghe-Teodor Bercea 9db6e861ac [OpenMP] Add an additional test for D34888
Summary: Test for checking if the mapping is performed correctly. This is a test initially included in Patch https://reviews.llvm.org/D29905

Reviewers: Hahnfeld, carlo.bertolli, caomhin

Reviewed By: Hahnfeld

Subscribers: tra, cfe-commits

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

llvm-svn: 314210
2017-09-26 14:56:50 +00:00
Ivan A. Kosarev b75a50b121 Fix TBAA information for reference accesses
This patch fixes clang to decorate reference accesses as pointers
and not as "omnipotent chars".

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

llvm-svn: 314209
2017-09-26 14:22:48 +00:00
Alexey Bataev f47c4b4184 [OPENMP] Generate implicit map|firstprivate clauses for target-based
directives.

If the variable is used in the target-based region but is not found in
any private|mapping clause, then generate implicit firstprivate|map
clauses for these implicitly mapped variables.

llvm-svn: 314205
2017-09-26 13:47:31 +00:00
Dean Michael Berris 7fb0545986 [XRay] Avoid actual linking when testing the driver
Use -### in the command to see just look for the output of -v.

Follow-up to D38226.

llvm-svn: 314194
2017-09-26 04:29:25 +00:00
Dean Michael Berris 8d10a87363 [XRay] Run command once without piping to FileCheck
This allows us to debug the failures that come up from the build bots.

Follow-up to D38226.

llvm-svn: 314193
2017-09-26 04:17:37 +00:00
Dean Michael Berris 394f388c20 [XRay] Only run shared tests when 'enable_shared' is true
Follow-up to D38226.

llvm-svn: 314191
2017-09-26 04:07:45 +00:00
Dean Michael Berris f686a90fb2 [XRay] Remove -fPIC from shared build test.
Follow-up to D38226.

llvm-svn: 314190
2017-09-26 04:00:41 +00:00
Dean Michael Berris e935cbe86f [XRay] Stop running tests for 'amd64', and remove -fPIE from tests.
Follow-up to D38226.

llvm-svn: 314189
2017-09-26 03:45:37 +00:00
Dean Michael Berris c67811ce1f [XRay][Driver] Do not link in XRay runtime in shared libs
Summary:
This change ensures that we don't link in the XRay runtime when building
shared libraries with clang. This doesn't prevent us from building
shared libraris tht have XRay instrumentation sleds, but it does prevent
us from linking in the static XRay runtime into a shared library.

The XRay runtime currently doesn't support dynamic registration of
instrumentation sleds in shared objects, which we'll start enabling in
the future. That work has to happen in the back-end and in the runtime.

Reviewers: rnk, pelikan

Subscribers: cfe-commits

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

llvm-svn: 314188
2017-09-26 03:18:11 +00:00
Matthias Braun bffc1bb2b2 CodeGenModule: Adapt to LLVM TargetLibraryInfo changes
Adapt to LLVM TargetLibraryInfo changes in r314185.

See also https://reviews.llvm.org/D38106 and https://reviews.llvm.org/D37891

llvm-svn: 314187
2017-09-26 02:37:23 +00:00
Dean Michael Berris 54f6893279 Revert "[XRay][Driver] Do not link in XRay runtime in shared libs"
Reverts r314177.

llvm-svn: 314178
2017-09-26 00:41:08 +00:00
Dean Michael Berris b013dc4b05 [XRay][Driver] Do not link in XRay runtime in shared libs
Summary:
This change ensures that we don't link in the XRay runtime when building
shared libraries with clang. This doesn't prevent us from building
shared libraris tht have XRay instrumentation sleds, but it does prevent
us from linking in the static XRay runtime into a shared library.

The XRay runtime currently doesn't support dynamic registration of
instrumentation sleds in shared objects, which we'll start enabling in
the future. That work has to happen in the back-end and in the runtime.

Reviewers: rnk, pelikan

Subscribers: cfe-commits

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

llvm-svn: 314177
2017-09-25 23:40:33 +00:00
Nico Weber e8eba3716c clang-format/java: Always put space after `assert` keyword.
Previously, it was missing if the expression after the assert started with a (.

llvm-svn: 314172
2017-09-25 22:42:49 +00:00
Vlad Tsyrklevich 2eccdab308 Allow specifying sanitizers in blacklists
Summary:
This is the follow-up patch to D37924.

This change refactors clang to use the the newly added section headers
in SpecialCaseList to specify which sanitizers blacklists entries
should apply to, like so:

  [cfi-vcall]
  fun:*bad_vcall*
  [cfi-derived-cast|cfi-unrelated-cast]
  fun:*bad_cast*

The SanitizerSpecialCaseList class has been added to allow querying by
SanitizerMask, and SanitizerBlacklist and its downstream users have been
updated to provide that information. Old blacklists not using sections
will continue to function identically since the blacklist entries will
be placed into a '[*]' section by default matching against all
sanitizers.

Reviewers: pcc, kcc, eugenis, vsk

Reviewed By: eugenis

Subscribers: dberris, cfe-commits, mgorny

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

llvm-svn: 314171
2017-09-25 22:11:12 +00:00