Commit Graph

192 Commits

Author SHA1 Message Date
Stephen Kelly d7b659b592 Port getLocStart -> getBeginLoc
Reviewers: teemperor!

Subscribers: jholewinski, whisperity, jfb, cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@339385 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-09 21:08:08 +00:00
Erich Keane f2421d2e1b [AST][1/4] Move the bit-fields from TagDecl, EnumDecl and RecordDecl into DeclContext
DeclContext has a little less than 8 bytes free due to the alignment
requirements on 64 bits archs. This set of patches moves the
bit-fields from classes deriving from DeclContext into DeclContext.

On 32 bits archs this increases the size of DeclContext by 4 bytes
but this is balanced by an equal or larger reduction in the size
of the classes deriving from it.

On 64 bits archs the size of DeclContext stays the same but
most of the classes deriving from it shrink by 8/16 bytes.
(-print-stats diff here https://reviews.llvm.org/D49728)
When doing an -fsyntax-only on all of Boost this result
in a 3.6% reduction in the size of all Decls and
a 1% reduction in the run time due to the lower cache
miss rate.

For now CXXRecordDecl is not touched but there is
an easy 6 (if I count correctly) bytes gain available there
by moving some bits from DefinitionData into the free
space of DeclContext. This will be the subject of another patch.

This patch sequence also enable the possibility of refactoring
FunctionDecl: To save space some bits from classes deriving from
FunctionDecl were moved to FunctionDecl. This resulted in a
lot of stuff in FunctionDecl which do not belong logically to it.
After this set of patches however it is just a simple matter of
adding a SomethingDeclBitfields in DeclContext and moving the
bits to it from FunctionDecl.

This first patch introduces the anonymous union in DeclContext
and all the *DeclBitfields classes holding the bit-fields, and moves
the bits from TagDecl, EnumDecl and RecordDecl into DeclContext.

This patch is followed by https://reviews.llvm.org/D49732,
https://reviews.llvm.org/D49733 and https://reviews.llvm.org/D49734.

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

Patch By: bricci



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338630 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-01 20:48:16 +00:00
Fangrui Song abdbb605f2 Remove trailing space
sed -Ei 's/[[:space:]]+$//' include/**/*.{def,h,td} lib/**/*.{cpp,h}

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338291 91177308-0d34-0410-b5e6-96231b3b80d8
2018-07-30 19:24:48 +00:00
Faisal Vali 9626b8d4ee Revert rC330794 and some dependent tiny bug fixes
See Richard's humbling feedback here: 
http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20180423/226482.html
http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20180423/226486.html

Wish I'd had the patience to solicit the feedback prior to committing :)

Sorry for the noise guys.

Thank you Richard for being the steward that clang deserves!





git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@330888 91177308-0d34-0410-b5e6-96231b3b80d8
2018-04-26 00:42:40 +00:00
Faisal Vali 45d663da56 [c++2a] [concepts] Add rudimentary parsing support for template concept declarations
This patch is a tweak of changyu's patch: https://reviews.llvm.org/D40381. It differs in that the recognition of the 'concept' token is moved into the machinery that recognizes declaration-specifiers - this allows us to leverage the attribute handling machinery more seamlessly.

See the test file to get a sense of the basic parsing that this patch supports. 

There is much more work to be done before concepts are usable...

Thanks Changyu!


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@330794 91177308-0d34-0410-b5e6-96231b3b80d8
2018-04-25 02:42:26 +00:00
Eugene Zelenko a204565a1d [AST] Fix some Clang-tidy modernize-use-auto warnings; other minor fixes (NFC).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@328826 91177308-0d34-0410-b5e6-96231b3b80d8
2018-03-29 20:51:59 +00:00
Vassil Vassilev 618519b96f D40901: Refactor lazy loading of template specializations. NFC
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@320763 91177308-0d34-0410-b5e6-96231b3b80d8
2017-12-14 23:30:18 +00:00
Richard Smith e9089c9a34 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.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@319605 91177308-0d34-0410-b5e6-96231b3b80d8
2017-12-02 02:48:42 +00:00
Eugene Zelenko b473c3d246 [AST] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@319376 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-29 22:39:22 +00:00
Serge Pavlov 9fadf2235f Refactor functions PrintTemplateArgumentList
These functions were defined as static members of TemplateSpecializationType.
Now they are moved to namespace level. Previously there were different
implementations for lists containing TemplateArgument and TemplateArgumentLoc,
now these implementations share the same code.

This change is a result of refactoring patch D40508. NFC.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@319178 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-28 16:14:14 +00:00
George Burgess IV 0b0a12c569 Add a destruct-on-exit function to ASTContext.
It looks like the only use of AddDeallocation is to indirectly call the
destructors of objects. In one case I found
(TypeAliasTemplateDecl::Common), the destructor is a nop, so registering
it to run later seems pointless.

All of the other *::Common types have non-trivial dtors, so deleting the
useless AddDeallocation felt somewhat fragile. Happy to kill it + turn
the is_trivial_dtor check into a static_assert if people think that'd be
better.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@295029 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-14 05:37:36 +00:00
Hubert Tong eac12edf43 [Concepts] Class template associated constraints
Summary:
This adds associated constraints as a property of class templates.
An error is produced if redeclarations are not similarly constrained.

Reviewers: rsmith, faisalv, aaron.ballman

Reviewed By: rsmith

Subscribers: cfe-commits, nwilson

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@294697 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-10 02:46:19 +00:00
Vassil Vassilev de0c61bab9 PR31469: Don't add friend template class decls to redecl chain in dependent contexts.
Fixes a crash in modules where the template class decl becomes the most recent
decl in the redeclaration chain and forcing the template instantiator try to
instantiate the friend declaration, rather than the template definition.
    
In practice, A::list<int> produces a TemplateSpecializationType
A::__1::list<int, allocator<type-parameter-0-0> >' failing to replace to
subsitute the default argument to allocator<int>.
    
Kudos Richard Smith (D28399).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@291753 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-12 09:16:26 +00:00
Richard Smith 12d117c5a5 When producing a name of a partial specialization in a diagnostic, use the
template arguments as written rather than the canonical template arguments,
so we print more user-friendly names for template parameters.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@290483 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-24 04:09:05 +00:00
Richard Smith 5d286f24ea Move generation of injected template arguments for a template parameter list
out of an internal function and into ASTContext; this is needed in template
argument deduction for P0522R0.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@290405 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-23 02:10:11 +00:00
Jonathan Roelofs 1057307a75 Delete tautological assertion.
After r256463, both the LHS and RHS now refer to the same variable. Before,
they referred to the member, the parameter respectively. Now GCC6's
-Wtautological-compare complains.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@288444 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-02 00:51:58 +00:00
Benjamin Kramer fd352be22e Retire llvm::alignOf in favor of C++11 alignof.
No functionality change intended.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@284730 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-20 14:27:22 +00:00
Hubert Tong 826aea87e9 Reapply r276069 with workaround for MSVC 2013
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@277286 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-30 22:33:34 +00:00
Hubert Tong 06a1ffe84a Revert r276069: MSVC bots not happy
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@276074 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-20 01:05:31 +00:00
Hubert Tong 2d4a61465e Concepts: Create space for requires-clause in TemplateParameterList; NFC
Summary:
Space for storing the //constraint-expression// of the
//requires-clause// associated with a `TemplateParameterList` is
arranged by taking a bit out of the `NumParams` field for the purpose
of determining whether there is a //requires-clause// or not, and by
adding to the trailing objects tied to the `TemplateParameterList`. An
accessor is provided.

An appropriate argument is supplied to `TemplateParameterList::Create`
at the various call sites.

Serialization changes will addressed as the Concepts implementation
becomes more solid.

Drive-by fix:
This change also replaces the custom
`FixedSizeTemplateParameterListStorage` implementation with one that
follows the interface provided by `llvm::TrailingObjects`.

Reviewers: aaron.ballman, faisalv, rsmith

Subscribers: cfe-commits, nwilson

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


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@276069 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-20 00:30:15 +00:00
Argyrios Kyrtzidis 753944f521 [AST] Keep track of the left brace source location of a tag decl.
This is useful for source modification tools. There will be a follow-up commit using it.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@275590 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-15 18:11:33 +00:00
David Majnemer ce09fec7c1 [AST] Use ArrayRef in more interfaces
ArrayRef is a little better than passing around a pointer/length
pair.

No functional change is intended.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@274732 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-07 04:43:07 +00:00
David Majnemer a66fce3e0f [AST] Use ArrayRef in more interfaces
ArrayRef is a little better than passing around a pointer/length pair.

No functional change is intended.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@274601 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-06 04:19:16 +00:00
David Majnemer 52de7439bc [AST] Use ArrayRef in more interfaces
ArrayRef is a little better than passing around a pointer/length pair.

No functional change is intended.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@274475 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-03 21:17:51 +00:00
Eric Fiselier fe36cf9482 [Feature] Add a builtin for indexing into parameter packs. Patch by Louis Dionne.
This patch adds a __nth_element builtin that allows fetching the n-th type of a
parameter pack with very little compile-time overhead. The patch was inspired by
r252036 and r252115 by David Majnemer, which add a similar __make_integer_seq
builtin for efficiently creating a std::integer_sequence.

Reviewed as D15421. http://reviews.llvm.org/D15421



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@274316 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-01 01:24:09 +00:00
David Majnemer e3b6e588e0 ArrayRef-ize TemplateParameterList. NFC
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@256463 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-27 07:16:27 +00:00
David Majnemer 6bb02a27b9 [Sema] Implement __make_integer_seq
This new builtin template allows for incredibly fast instantiations of
templates like std::integer_sequence.

Performance numbers follow:
My work station has 64 GB of ram + 20 Xeon Cores at 2.8 GHz.

__make_integer_seq<std::integer_sequence, int, 90000> takes 0.25
seconds.

std::make_integer_sequence<int, 90000> takes unbound time, it is still
running.  Clang is consuming gigabytes of memory.

Differential Revision: http://reviews.llvm.org/D13786

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@252036 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-04 03:40:30 +00:00
James Y Knight 1c07720974 Convert a few classes over to use the new TrailingObjects helper.
This initial commit serves as an example -- the remainder of the
classes using pointer arithmetic for trailing objects will be
converted in subsequent changes.

Differential Revision: http://reviews.llvm.org/D11298

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@244262 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-06 20:26:32 +00:00
James Y Knight dc40f2e4ea Remove unused 'Owned' flag from TemplateArgumentList.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@244261 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-06 20:26:18 +00:00
Benjamin Kramer 66889e0179 [AST] ArrayRefize template argument packs. No functionality change intended.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@244026 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-05 09:40:22 +00:00
Richard Smith a5c46dbe18 [modules] Improve diagnostic for a template-id that's invalid because a default
argument is not visible.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@239934 91177308-0d34-0410-b5e6-96231b3b80d8
2015-06-17 20:16:32 +00:00
Richard Smith fc970014c2 [modules] Track all default template arguments for a given parameter across
modules, and allow use of a default template argument if any of the parameters
providing it is visible.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@239485 91177308-0d34-0410-b5e6-96231b3b80d8
2015-06-10 20:30:23 +00:00
Richard Smith 29269f9e48 Refactor storage of default template arguments.
This is just a preparatory step towards fixing visibility for default template
arguments in modules builds.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@239447 91177308-0d34-0410-b5e6-96231b3b80d8
2015-06-10 00:29:03 +00:00
Richard Smith 4b16d54f97 [modules] Ensure we've imported all declarations of a template before
attempting to lazily deserialize its specializations; otherwise, there might be
pending specializations that we don't know about yet.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@230301 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-24 02:44:23 +00:00
Richard Smith 89afb52800 Refactor *TemplateDecl::addSpecialization to reduce duplication and add some
more asserts.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@230296 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-24 01:23:23 +00:00
Craig Topper bbd68e1f18 Convert some function arguments to use ArrayRef.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@211764 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-26 04:58:53 +00:00
Richard Smith 3ad9bfabb6 If a declaration is loaded, and then a module import adds a redeclaration, then
ensure that querying the first declaration for its most recent declaration
checks for redeclarations from the imported module.

This works as follows:
 * The 'most recent' pointer on a canonical declaration grows a pointer to the
   external AST source and a generation number (space- and time-optimized for
   the case where there is no external source).
 * Each time the 'most recent' pointer is queried, if it has an external source,
   we check whether it's up to date, and update it if not.
 * The ancillary data stored on the canonical declaration is allocated lazily
   to avoid filling it in for declarations that end up being non-canonical.
   We'll still perform a redundant (ASTContext) allocation if someone asks for
   the most recent declaration from a decl before setPreviousDecl is called,
   but such cases are probably all bugs, and are now easy to find.

Some finessing is still in order here -- in particular, we use a very general
mechanism for handling the DefinitionData pointer on CXXRecordData, and a more
targeted approach would be more compact.

Also, the MayHaveOutOfDateDef mechanism should now be expunged, since it was
addressing only a corner of the full problem space here. That's not covered
by this patch.

Early performance benchmarks show that this makes no measurable difference to 
Clang performance without modules enabled (and fixes a major correctness issue
with modules enabled). I'll revert if a full performance comparison shows any
problems.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@209046 91177308-0d34-0410-b5e6-96231b3b80d8
2014-05-16 23:01:30 +00:00
Craig Topper 613c4e1cde [C++11] Use 'nullptr'. AST edition.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@208517 91177308-0d34-0410-b5e6-96231b3b80d8
2014-05-12 05:36:57 +00:00
Richard Smith b21ef91f7d Make TypeDecl much less friendly.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@207007 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-23 18:20:42 +00:00
Richard Smith e0b111b667 Clean up variable template handling a bit, and correct the behavior of name
lookup when declaring a variable template specialization.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@199438 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-16 23:39:20 +00:00
Alp Toker 0fb7888788 Fix a tranche of comment, test and doc typos
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@196510 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-05 16:25:25 +00:00
Richard Smith 4903ea2c65 Add class-specific operator new to Decl hierarchy. This guarantees that Decls
can't accidentally be allocated the wrong way (missing prefix data for decls
from AST files, for instance) and simplifies the CreateDeserialized functions a
little. An extra DeclContext* parameter to the not-from-AST-file operator new
allows us to ensure that we don't accidentally call the wrong one when
deserializing (when we don't have a DeclContext), allows some extra checks, and
prepares for some planned modules-related changes to Decl allocation.

No functionality change intended.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@195426 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-22 09:01:48 +00:00
Rafael Espindola 9297535638 Reduce indentation with an early exit.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@193028 91177308-0d34-0410-b5e6-96231b3b80d8
2013-10-19 02:28:17 +00:00
Rafael Espindola bc6509175e Rename some functions for consistency.
Every other function in Redeclarable.h was using Decl instead of Declaration.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@192900 91177308-0d34-0410-b5e6-96231b3b80d8
2013-10-17 15:37:26 +00:00
Larisse Voufo 8d2a5ea694 A clean-up pass, exploring the unification of traversals of class, variable and function templates.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@189152 91177308-0d34-0410-b5e6-96231b3b80d8
2013-08-23 22:21:36 +00:00
Richard Smith 37fd27dbb9 Remove SequenceNumber from class/variable template partial specializations.
This was only used to ensure that the traversal order was the same as the
insertion order, but that guarantee was already being provided by the use
of a FoldingSetVector.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@189075 91177308-0d34-0410-b5e6-96231b3b80d8
2013-08-22 23:27:37 +00:00
Larisse Voufo 439d665f4d variable templates updated for PCH serialization... Still working on test cases...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@188249 91177308-0d34-0410-b5e6-96231b3b80d8
2013-08-13 02:02:26 +00:00
Enea Zaffanella c1cef0892e Added source locs for angled parentheses in class/var template partial specs.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@188134 91177308-0d34-0410-b5e6-96231b3b80d8
2013-08-10 07:24:53 +00:00
Larisse Voufo ef4579cda0 Started implementing variable templates. Top level declarations should be fully supported, up to some limitations documented as FIXMEs or TODO. Static data member templates work very partially. Static data member templates of class templates need particular attention...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@187762 91177308-0d34-0410-b5e6-96231b3b80d8
2013-08-06 01:03:05 +00:00
Richard Smith 6982bf4d77 Lazily deserialize function template specializations. This fixes a cycle in
module deserialization / merging, and more laziness here is general goodness.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@185132 91177308-0d34-0410-b5e6-96231b3b80d8
2013-06-28 04:37:53 +00:00