This is an archive of the discontinued LLVM Phabricator instance.

Concepts: Create space for requires-clause in TemplateParameterList; NFC
ClosedPublic

Authored by hubert.reinterpretcast on Apr 20 2016, 6:15 AM.

Details

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.

Diff Detail

Event Timeline

hubert.reinterpretcast retitled this revision from to Concepts: Create space for requires-clause in TemplateParameterList; NFC.
hubert.reinterpretcast updated this object.
hubert.reinterpretcast added a subscriber: nwilson.

Store the RequiresClause expression into the created storage;
add accessor;
add unnecessary parens to silence warning

Actually add parens this time

faisalv added inline comments.Apr 21 2016, 9:57 AM
include/clang/AST/DeclTemplate.h
174

Yuk - this entire guy (FizedSizeTemplateParameterListStorage) seems quite fragile (dependent on object layout) - are the gains (in the single use below during auto-type deduction) in preformance really worth the introduction of this fragility/ugliness?
Unless there is a clear win from this strategy, I think i'd favor (perhaps in a later patch) - either just removing this structure and using TPL for the use-case in auto-type below, or using placement new and creating the stack TPL on a stack unsigned char array?
Thoughts?

include/clang/AST/DeclTemplate.h
174

I don't like the class here either; however, I would not like to introduce heap allocation just to remove it. placement-new is certainly part of the solution. I think that TrailingObjects should have an alias for a type that can be used as aligned storage (templated in the style of totalSizeToAlloc). I would like to keep that endeavour to a separate patch though.

Address Faisal's comment; supercedes D19771

Replaces the custom FixedSizeTemplateParameterListStorage implementation with one that follows the interface provided by llvm::TrailingObjects.

hubert.reinterpretcast marked 2 inline comments as done.May 2 2016, 11:09 AM

@rsmith; I've addressed Faisal's comment. Please let me know if this patch (and D19770) is good to go. If it isn't ready yet, I'd like your opinion on D19770+D19771.

Set requires-clause when creating TemplateParameterLists; NFC

Removes the default argument for the requires-clause constraint expression in TemplateParameterList::Create.

An appropriate argument is supplied at the various call sites. Serialization changes will be left until the feature is otherwise complete so that the version number does not need to be bumped multiple times.

rsmith accepted this revision.Jul 14 2016, 2:42 PM
rsmith edited edge metadata.
rsmith added inline comments.
lib/AST/ASTImporter.cpp
2253–2254

else on same line as } please.

This revision is now accepted and ready to land.Jul 14 2016, 2:42 PM
hubert.reinterpretcast edited edge metadata.