1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Bug 540252: Fix formatting operator< with explicit instantiation

A space must be forced in this special case even if preferences
say something different.

Change-Id: Ie43b988139913f87590f4f1460d28e79f9bd7ef8
Signed-off-by: Marco Stornelli <marco.stornelli@gmail.com>
This commit is contained in:
Marco Stornelli 2019-03-02 15:29:19 +01:00 committed by Jonah Graham
parent 659432f7e2
commit f28b158828
2 changed files with 29 additions and 2 deletions

View file

@ -3570,8 +3570,12 @@ public class CodeFormatterVisitor extends ASTVisitor implements ICPPASTVisitor,
IASTName name = node.getTemplateName();
name.accept(this);
if (peekNextToken() == Token.tLT) {
scribe.printNextToken(Token.tLT,
preferences.insert_space_before_opening_angle_bracket_in_template_arguments);
char[] simpleId = name.getSimpleID();
if (simpleId[simpleId.length - 1] == '<')
scribe.printNextToken(Token.tLT, true);
else
scribe.printNextToken(Token.tLT,
preferences.insert_space_before_opening_angle_bracket_in_template_arguments);
if (preferences.insert_space_after_opening_angle_bracket_in_template_arguments) {
scribe.space();
}

View file

@ -3758,4 +3758,27 @@ public class CodeFormatterTest extends BaseUITestCase {
public void testTemplateIdWithMacro4_Bug406231() throws Exception {
assertFormatterResult();
}
//class data
//{
//public:
// template <class x> bool operator< (x const &n) const
// {
// return n < 0;
// }
//};
////explicit instantiation
//template bool data::operator< <int>(int const &) const;
//class data {
//public:
// template<class x> bool operator<(x const &n) const {
// return n < 0;
// }
//};
////explicit instantiation
//template bool data::operator< <int>(int const &) const;
public void testTemplateInstantiationOperatorLesser_Bug540252() throws Exception {
assertFormatterResult();
}
}