Commit Graph

2305 Commits

Author SHA1 Message Date
Cameron Desrochers b60f1b6d3d [PCH] Serialize skipped preprocessor ranges
The skipped preprocessor ranges are now serialized in the AST PCH file. This fixes, for example, libclang's clang_getSkippedRanges() returning zero ranges after reparsing a translation unit.

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

llvm-svn: 322503
2018-01-15 19:14:16 +00:00
Aaron Ballman a503855906 Track in the AST whether the operand to a UnaryOperator can overflow and then use that logic when evaluating constant expressions and emitting codegen.
llvm-svn: 322074
2018-01-09 13:07:03 +00:00
Erich Keane 281d20b601 Implement Attribute Target MultiVersioning
GCC's attribute 'target', in addition to being an optimization hint,
also allows function multiversioning. We currently have the former
implemented, this is the latter's implementation.

This works by enabling functions with the same name/signature to coexist,
so that they can all be emitted. Multiversion state is stored in the
FunctionDecl itself, and SemaDecl manages the definitions.
Note that it ends up having to permit redefinition of functions so
that they can all be emitted. Additionally, all versions of the function
must be emitted, so this also manages that.

Note that this includes some additional rules that GCC does not, since
defining something as a MultiVersion function after a usage has been made illegal.

The only 'history rewriting' that happens is if a function is emitted before
it has been converted to a multiversion'ed function, at which point its name
needs to be changed.

Function templates and virtual functions are NOT yet supported (not supported
in GCC either).

Additionally, constructors/destructors are disallowed, but the former is 
planned.

llvm-svn: 322028
2018-01-08 21:34:17 +00:00
Richard Smith a263c346e5 Serialize the IDNS for a UsingShadowDecl rather than recomputing it.
Attempting to recompute it are doomed to fail because the IDNS of a declaration
is not necessarily preserved across serialization and deserialization (in turn
because whether a friend declaration is visible depends on whether some prior
non-friend declaration exists).

llvm-svn: 321921
2018-01-06 01:07:05 +00:00
Evgeny Stupachenko bf25d67b8c NFC.
The patch fixes r321395, that cuased
 -Werror=unused-but-set-variable issue for
 Diagnosed var on prod build.

From: Evgeny Stupachenko <evstupac@gmail.com>
llvm-svn: 321854
2018-01-05 02:22:52 +00:00
Faisal Vali 090da2d1ac Again reverting an attempt to convert the DeclSpec enums into scoped enums.
- reverts r321622, r321625, and r321626.
  - the use of bit-fields is still resulting in warnings - even though we can use static-asserts to harden the code and ensure the bit-fields are wide enough.  The bots still complain of warnings being seen.
  - to silence the warnings requires specifying the bit-fields with the underlying enum type (as opposed to the enum type itself), which then requires lots of unnecessary static casts of each enumerator within DeclSpec to the underlying-type, which even though could be seen as implementation details, it does hamper readability - and given the additional litterings, makes me question the value of the change.

So in short - I give up (for now at least).  

Sorry about the noise.

llvm-svn: 321628
2018-01-01 18:23:28 +00:00
Faisal Vali 038df49033 [NFC] Modernize enums TypeSpecifierWidth, TypeSpecifierSign & TypeSpecifierType into scoped enums with underlying types.
- Since these enums are used as bit-fields - for the bit-fields to be interpreted as unsigned, the underlying type must be specified as unsigned.

Previous failed attempt - wherein I did not specify an underlying type - was the sum of:
https://reviews.llvm.org/rC321614
https://reviews.llvm.org/rC321615

llvm-svn: 321622
2018-01-01 15:42:13 +00:00
Faisal Vali c535adcfc5 Revert r321614 and r321615
- the enum changes to TypeSpecifierType are breaking some tests - and will require a more careful integration.

Sorry about rushing these changes - thought I could sneak them in prior to heading out for new years ;)

llvm-svn: 321616
2018-01-01 02:49:17 +00:00
Faisal Vali 4a85f14c19 Add scope specifiers to updated scoped-enums (that I somehow missed in r321614)
llvm-svn: 321615
2018-01-01 02:35:43 +00:00
Benjamin Kramer 0742090e3d [AST] Inline CompoundStmt contents into the parent allocation.
Saves a pointer on every CompoundStmt.

llvm-svn: 321429
2017-12-24 16:24:20 +00:00
Richard Trieu e6caa26e5d [ODRHash] Support ODR violation detection in functions.
Extend the hashing to functions, which allows detection of function definition
mismatches across modules.  This is a re-commit of r320230.

llvm-svn: 321395
2017-12-23 00:41:01 +00:00
Benjamin Kramer acfa339e15 Refactor overridden methods iteration to avoid double lookups.
Convert most uses to range-for loops. No functionality change intended.

llvm-svn: 320954
2017-12-17 23:52:45 +00:00
Richard Trieu c4ec87af1d Revert r320230 to fix buildbots.
llvm-svn: 320239
2017-12-09 03:02:21 +00:00
Richard Trieu e81caeb314 [ODRHash] Support ODR violation detection in functions.
Extend the hashing to functions, which allows detection of function definition
mismatches across modules.

llvm-svn: 320230
2017-12-09 01:29:40 +00:00
Richard Smith 891fc7f37a Generalize "static data member instantiated" notification to cover variable templates too.
While here, split the "point of instantiation changed" notification out from
it; these two really are orthogonal changes.

llvm-svn: 319727
2017-12-05 01:31:47 +00:00
Hans Wennborg 1448736e49 Correctly handle line table entries without filenames during AST serialization
The current code would hit an assert in ASTWriter when trying to write
out the filename for a line table entry that didn't have any. Fix this
by allowing the -1 sentinel value to round-trip through serialization.

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

llvm-svn: 319707
2017-12-04 22:28:45 +00:00
Aaron Ballman c351fba69e Now that C++17 is official (https://www.iso.org/standard/68564.html), start changing the C++1z terminology over to C++17. NFC intended, these are all mechanical changes.
llvm-svn: 319688
2017-12-04 20:27:34 +00:00
Richard Smith 435e647a41 PR35456: Track definedness of variable template specializations separately from
whether they have an initializer.

We cannot distinguish between a declaration of a variable template
specialization and a definition of one that lacks an initializer without this,
and would previously mistake the latter for the former.

llvm-svn: 319605
2017-12-02 02:48:42 +00:00
Alexey Bataev 16e798873e [OPENMP] Add support for cancel constructs in `target teams distribute
parallel for`.

Add support for cancel/cancellation point directives inside `target
teams distribute parallel for` directives.

llvm-svn: 318881
2017-11-22 21:12:03 +00:00
Alexey Bataev dcb4b8fbc1 [OPENMP] Add support for cancel constructs in [teams] distribute
parallel for directives.

Added codegen/sema support for cancel constructs in [teams] distribute
parallel for directives.

llvm-svn: 318872
2017-11-22 20:19:50 +00:00
Bruno Cardoso Lopes a66a325bbc [PCH+Modules] Improve diagnosticts to help out users pass an extra header search path
When mixing PCH and Implicit Modules, missing a header search path
can lead to the implicit built PCM to complaint about not finding its
matching module map.

Instead of adding more magic to implicit modules engine, add a note to
help the user add the appropriate path.

rdar://problem/33388847

llvm-svn: 318503
2017-11-17 03:24:11 +00:00
Faisal Vali 1f3a2af902 Adjust r316292 - remove the anonymous union for sharing a bitfield in FunctionDecl.
The anonymous union did NOT save us storage, but instead behaved as if we added an additional integer data member to FunctionDecl.  

For additional context, the anonymous union renders the bit fields as non-adjacent and prevents them from sharing the same 'memory location' (i.e. bit-storage) by requiring the anonymous union object to be appropriately aligned.

This was confirmed through discussion with Richard Smith in Albuquerque (ISO C++ Meeting)

https://reviews.llvm.org/rL316292

llvm-svn: 317984
2017-11-11 18:02:29 +00:00
Eugene Zelenko b7d89107cd [Serialization] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).
llvm-svn: 317953
2017-11-11 00:08:50 +00:00
Eugene Zelenko b8c9e2aae5 [Serialization] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).
llvm-svn: 317648
2017-11-08 01:03:16 +00:00
Erik Verbruggen 4d1eb2d5cb [preamble] Also record the "skipping" state of the preprocessor
When a preamble ends in a conditional preprocessor block that is being
skipped, the preprocessor needs to continue skipping that block when
the preamble is used.

This fixes PR34570.

llvm-svn: 317308
2017-11-03 09:40:07 +00:00
David Blaikie 1524e67feb Modular Codegen: Don't home always_inline functions
Since they'll likely (not always - if the address is taken, etc) be
inlined away, even at -O0, separately provided weak definitions are
likely to be unused so skip all of that.

llvm-svn: 317279
2017-11-02 22:28:50 +00:00
David Blaikie 0826729793 Modular Codegen: Don't home/modularize static functions in headers
Consistent with various workarounds in the backwards compatible modules
that allow static functions in headers to exist, be deduplicated to some
degree, and not generally fail right out of the gate... do the same with
modular codegen as there are enough cases (including in libstdc++ and in
LLVM itself - though I cleaned up the easy ones) that it's worth
supporting as a migration/backcompat step.

Simply create a separate, internal linkage function in each object that
needs it. If an available_externally/modularized function references a
static function, but the modularized function is eventually dropped and
not inlined, the static function will be dropped as unreferenced.

llvm-svn: 317274
2017-11-02 21:55:40 +00:00
Eugene Zelenko 4b3289e84f [Serialization] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).
llvm-svn: 317273
2017-11-02 21:45:30 +00:00
Richard Smith f501759a85 PR33746: Store the 'inline'ness of a static data member with the update record
for instantiating its definition.

We model the 'inline'ness as being instantiated with the static data member in
order to track whether the declaration has become a definition yet.

llvm-svn: 317147
2017-11-02 01:06:00 +00:00
Faisal Vali 81b756e6a3 [C++17] Fix PR34970 - tweak overload resolution for class template deduction-guides in line with WG21's p0620r0.
In order to identify the copy deduction candidate, I considered two approaches:
  - attempt to determine whether an implicit guide is a copy deduction candidate by checking certain properties of its subsituted parameter during overload-resolution.
  - using one of the many bits (WillHaveBody) from FunctionDecl (that CXXDeductionGuideDecl inherits from) that are otherwise irrelevant for deduction guides

After some brittle gymnastics w the first strategy, I settled on the second, although to avoid confusion and to give that bit a better name, i turned it into a member of an anonymous union.

Given this identification 'bit', the tweak to overload resolution was a simple reordering of the deduction guide checks (in SemaOverload.cpp::isBetterOverloadCandidate), in-line with Jason Merrill's p0620r0 drafting which made it into the working paper.  Concordant with that, I made sure the copy deduction candidate is always added.


References:
See https://bugs.llvm.org/show_bug.cgi?id=34970 
See http://wg21.link/p0620r0

llvm-svn: 316292
2017-10-22 14:45:08 +00:00
Richard Smith 5b34958b46 Support for destroying operator delete, per C++2a proposal P0722.
This feature is not (yet) approved by the C++ committee, so this is liable to
be reverted or significantly modified based on committee feedback.

No functionality change intended for existing code (a new type must be defined
in namespace std to take advantage of this feature).

llvm-svn: 315662
2017-10-13 01:55:36 +00:00
NAKAMURA Takumi 12ab07e000 Fix warnings. [-Wdocumentation]
llvm-svn: 315573
2017-10-12 09:42:14 +00:00
Daniel Jasper 4a6d5b72af Revert r314955: "Remove PendingBody mechanism for function and ObjC method deserialization."
This is breaking a build of https://github.com/abseil/abseil-cpp and so
likely not really NFC. Also reverted subsequent r314956/7.

I'll forward reproduction instructions to Richard.

llvm-svn: 315439
2017-10-11 07:47:54 +00:00
Simon Pilgrim 22518632cd Fix a (slightly weird) 'comma operator within array index expression' warning on VS builds. NFCI.
llvm-svn: 315314
2017-10-10 13:56:17 +00:00
Richard Smith b80e7533bf PR33924: Merge block-scope anonymous declarations if there are multiple definitions of the enclosing function.
llvm-svn: 314956
2017-10-05 00:47:24 +00:00
Richard Smith 3ea492ad74 Remove PendingBody mechanism for function and ObjC method deserialization.
In its place, track on the canonical function declaration whether there is a
declaration with a body (and if so, which one). This brings function definition
handling in line with what we do in all other contexts, and is necessary to
allow us to merge declarations within multiple definitions of the same function
(eg, PR33924).

No functionality change intended.

llvm-svn: 314955
2017-10-05 00:43:38 +00:00
Alexey Bataev 931e19bf51 [OPENMP] Capture argument of `device` clause for target-based
directives.

The argument of the `device` clause in target-based executable
directives must be captured to support codegen for the `target`
directives with the `depend` clauses.

llvm-svn: 314686
2017-10-02 16:32:39 +00:00
Andrew Gozillon 572bbb0754 Dependent Address Space Support
This patch relates to: https://reviews.llvm.org/D33666 This adds support
for template parameters to be passed to the address_space attribute. 
The main goal is to add further flexibility to the attribute and allow 
for it to be used easily with templates.

The main additions are a new type (DependentAddressSpaceType) alongside 
its TypeLoc and its mangling. As well as the logic required to support 
dependent address spaces which mainly resides in TreeTransform.h and 
SemaType.cpp.

llvm-svn: 314649
2017-10-02 06:25:51 +00:00
Richard Trieu e13eabe7d3 [ODRHash] Add base classes to hashing CXXRecordDecl.
llvm-svn: 314581
2017-09-30 02:19:17 +00:00
Douglas Gregor badae3ff04 Minor cleanups to address feedback from Bruno. NFC
llvm-svn: 313318
2017-09-14 23:40:51 +00:00
Douglas Gregor f0b11de279 [Module map] Introduce a private module re-export directive.
Introduce a new "export_as" directive for top-level modules, which
indicates that the current module is a "private" module whose symbols
will eventually be exported through the named "public" module. This is
in support of a common pattern in the Darwin ecosystem where a single
public framework is constructed of several private frameworks, with
(currently) header duplication and some support from the linker.

Addresses rdar://problem/34438420.

llvm-svn: 313316
2017-09-14 23:38:44 +00:00
Sjoerd Meijer cc623ad071 Recommit "Add _Float16 as a C/C++ source language type"
This is a recommit of r312781; in some build configurations
variable names are omitted, so changed the new regression
test accordingly.

llvm-svn: 312794
2017-09-08 15:15:00 +00:00
Sjoerd Meijer 9aeedde7ff Revert "Add _Float16 as a C/C++ source language type"
The clang-with-lto-ubuntu bot didn't like the new regression
test, revert while I investigate the issue.

llvm-svn: 312784
2017-09-08 10:20:52 +00:00
Sjoerd Meijer ab36f33db8 Add _Float16 as a C/C++ source language type
This adds _Float16 as a source language type, which is a 16-bit floating point
type defined in C11 extension ISO/IEC TS 18661-3.

In follow up patches documentation and more tests will be added.

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

llvm-svn: 312781
2017-09-08 09:42:32 +00:00
Richard Smith cd4a7a461f [modules ts] Ensure that module linkage variables are always emitted and always have their name mangled.
llvm-svn: 312684
2017-09-07 00:55:55 +00:00
Richard Smith a465362d77 [modules ts] Emit global variables in a module interface unit as part of that unit, not in importers.
llvm-svn: 312665
2017-09-06 20:01:14 +00:00
Alexey Bataev 070f43aee7 [OPENMP] Fix for PR34445: Reduction initializer segfaults at runtime in
move constructor.

Previously user-defined reduction initializer was considered as an
assignment expression, not as initializer. Fixed this by treating the
initializer expression as an initializer.

llvm-svn: 312638
2017-09-06 14:49:58 +00:00
Simon Pilgrim f331a6642b Fix MSVC narrowing conversion warning.
llvm-svn: 312479
2017-09-04 10:54:39 +00:00
Richard Smith dd8b5337e9 Implement Itanium name mangling support for C++ Modules TS.
This follows the scheme agreed with Nathan Sidwell, which can be found here:

  https://gcc.gnu.org/wiki/cxx-modules?action=AttachFile

This will be proposed to the itanium-cxx-abi list once we have some experience
with how well it works; the ABI for this TS should be considered unstable until
it is part of the Itanium C++ ABI.

llvm-svn: 312467
2017-09-04 05:37:53 +00:00
Boris Kolpackov d30446fd77 [modules] Add ability to specify module name to module file mapping (reapply)
Extend the -fmodule-file option to support the [<name>=]<file> value format.
If the name is omitted, then the old semantics is preserved (the module file
is loaded whether needed or not). If the name is specified, then the mapping
is treated as just another prebuilt module search mechanism, similar to
-fprebuilt-module-path, and the module file is only loaded if actually used
(e.g., via import). With one exception: this mapping also overrides module
file references embedded in other modules (which can be useful if module files
are moved/renamed as often happens during remote compilation).

This override semantics requires some extra work: we now store the module name
in addition to the file name in the serialized AST representation.

Reviewed By: rsmith

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

llvm-svn: 312220
2017-08-31 06:26:43 +00:00