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

Cosmetics.

This commit is contained in:
Sergey Prigogin 2013-04-02 18:40:45 -07:00
parent 051c64bc24
commit c055318726
2 changed files with 46 additions and 44 deletions

View file

@ -5880,7 +5880,7 @@ public class AST2TemplateTests extends AST2TestBase {
// //
// template <class Container> // template <class Container>
// auto begin1(Container cont) -> decltype(cont.begin()); // auto begin1(Container cont) -> decltype(cont.begin());
// //
// template <class Container> // template <class Container>
// auto begin2(Container& cont) -> decltype(cont.begin()); // auto begin2(Container& cont) -> decltype(cont.begin());
// //
@ -5892,7 +5892,7 @@ public class AST2TemplateTests extends AST2TestBase {
helper.assertVariableType("x1", CommonTypes.pointerToInt); helper.assertVariableType("x1", CommonTypes.pointerToInt);
helper.assertVariableType("x2", CommonTypes.pointerToInt); helper.assertVariableType("x2", CommonTypes.pointerToInt);
} }
// struct vector { // struct vector {
// int* begin(); // int* begin();
// const int* begin() const; // const int* begin() const;
@ -5912,7 +5912,7 @@ public class AST2TemplateTests extends AST2TestBase {
public void testResolvingAutoTypeWithDependentExpression_402409b() throws Exception { public void testResolvingAutoTypeWithDependentExpression_402409b() throws Exception {
parseAndCheckBindings(); parseAndCheckBindings();
} }
// void foo(int, int); // void foo(int, int);
// template <typename... Args> void bar(Args... args) { // template <typename... Args> void bar(Args... args) {
// foo(1,2,args...); // foo(1,2,args...);
@ -6212,7 +6212,7 @@ public class AST2TemplateTests extends AST2TestBase {
public void testPointerToMemberAsDependentExpression_391001() throws Exception { public void testPointerToMemberAsDependentExpression_391001() throws Exception {
parseAndCheckBindings(getAboveComment(), CPP, true); parseAndCheckBindings(getAboveComment(), CPP, true);
} }
// template<typename> // template<typename>
// struct A { // struct A {
// char x; // char x;
@ -6999,11 +6999,11 @@ public class AST2TemplateTests extends AST2TestBase {
public void testSFINAEInDefaultArgument() throws Exception { public void testSFINAEInDefaultArgument() throws Exception {
parseAndCheckBindings(); parseAndCheckBindings();
} }
// typedef char (&no_tag)[1]; // typedef char (&no_tag)[1];
// typedef char (&yes_tag)[2]; // typedef char (&yes_tag)[2];
// //
// template <typename T> // template <typename T>
// struct type_wrapper {}; // struct type_wrapper {};
// //
// template <typename T> // template <typename T>
@ -7024,7 +7024,7 @@ public class AST2TemplateTests extends AST2TestBase {
assertNotNull(val); assertNotNull(val);
assertEquals(0 /* false */, val.longValue()); assertEquals(0 /* false */, val.longValue());
} }
// template <typename> // template <typename>
// struct M { // struct M {
// template <typename... Args> // template <typename... Args>
@ -7140,7 +7140,7 @@ public class AST2TemplateTests extends AST2TestBase {
} }
// template <int...> struct A {}; // template <int...> struct A {};
// template <int... I> void foo(A<I...>); // template <int... I> void foo(A<I...>);
// int main() { // int main() {
// foo(A<0>()); // foo(A<0>());
// } // }
@ -7160,10 +7160,10 @@ public class AST2TemplateTests extends AST2TestBase {
// struct contains_foo { // struct contains_foo {
// static const bool value = ice_or<is_foo<Args>::value...>::value; // static const bool value = ice_or<is_foo<Args>::value...>::value;
// }; // };
// template <bool> // template <bool>
// struct meta; // struct meta;
// struct S { void bar(); }; // struct S { void bar(); };
// template <> // template <>
// struct meta<false> { // struct meta<false> {
// typedef S type; // typedef S type;
// }; // };
@ -7204,7 +7204,7 @@ public class AST2TemplateTests extends AST2TestBase {
public void testClassTemplateSpecializationPartialOrdering_398044b() throws Exception { public void testClassTemplateSpecializationPartialOrdering_398044b() throws Exception {
parseAndCheckBindings(); parseAndCheckBindings();
} }
// template <typename T> // template <typename T>
// struct waldo { // struct waldo {
// typedef int type; // typedef int type;
@ -7217,7 +7217,7 @@ public class AST2TemplateTests extends AST2TestBase {
public void testPartialSpecializationForVarargFunctionType_402807() throws Exception { public void testPartialSpecializationForVarargFunctionType_402807() throws Exception {
parseAndCheckBindings(); parseAndCheckBindings();
} }
// template <typename> // template <typename>
// struct meta { // struct meta {
// static const bool value = 1; // static const bool value = 1;
@ -7241,7 +7241,7 @@ public class AST2TemplateTests extends AST2TestBase {
public void testRegression_399142() throws Exception { public void testRegression_399142() throws Exception {
parseAndCheckBindings(); parseAndCheckBindings();
} }
// template <class T> // template <class T>
// struct A { // struct A {
// struct impl { // struct impl {
@ -7257,7 +7257,7 @@ public class AST2TemplateTests extends AST2TestBase {
public void testDependentExpressionInvolvingFieldInNestedClass_399362() throws Exception { public void testDependentExpressionInvolvingFieldInNestedClass_399362() throws Exception {
parseAndCheckBindings(); parseAndCheckBindings();
} }
// template <typename _Tp> // template <typename _Tp>
// struct remove_reference { // struct remove_reference {
// typedef _Tp type; // typedef _Tp type;
@ -7357,7 +7357,7 @@ public class AST2TemplateTests extends AST2TestBase {
public void testNameLookupInDependentExpression_399829b() throws Exception { public void testNameLookupInDependentExpression_399829b() throws Exception {
parseAndCheckBindings(); parseAndCheckBindings();
} }
// template <bool> int assertion_failed(void*); // template <bool> int assertion_failed(void*);
// struct assert_ {}; // struct assert_ {};
// assert_ arg; // assert_ arg;
@ -7402,7 +7402,6 @@ public class AST2TemplateTests extends AST2TestBase {
BindingAssertionHelper helper = new BindingAssertionHelper(getAboveComment(), true); BindingAssertionHelper helper = new BindingAssertionHelper(getAboveComment(), true);
helper.assertProblem("bind(s, 0, foo)", "bind"); helper.assertProblem("bind(s, 0, foo)", "bind");
} }
// template<typename T> // template<typename T>
// T forward(T); // T forward(T);
@ -7432,7 +7431,7 @@ public class AST2TemplateTests extends AST2TestBase {
public void testVariadicNonTypeTemplateParameter_401142() throws Exception { public void testVariadicNonTypeTemplateParameter_401142() throws Exception {
parseAndCheckBindings(); parseAndCheckBindings();
} }
// template <bool... Args> // template <bool... Args>
// struct ice_or; // struct ice_or;
// template <> // template <>
@ -7454,7 +7453,7 @@ public class AST2TemplateTests extends AST2TestBase {
public void testVariadicNonTypeTemplateParameter_401400() throws Exception { public void testVariadicNonTypeTemplateParameter_401400() throws Exception {
parseAndCheckBindings(); parseAndCheckBindings();
} }
// template <typename... Args> // template <typename... Args>
// struct foo { // struct foo {
// static constexpr int i = sizeof...(Args); // static constexpr int i = sizeof...(Args);
@ -7475,7 +7474,7 @@ public class AST2TemplateTests extends AST2TestBase {
// struct make_indices_imp<Sp, tuple_indices<Indices...>, Ep> { // struct make_indices_imp<Sp, tuple_indices<Indices...>, Ep> {
// typedef typename make_indices_imp<Sp + 1, tuple_indices<Indices..., Sp>, Ep>::type type; // typedef typename make_indices_imp<Sp + 1, tuple_indices<Indices..., Sp>, Ep>::type type;
// }; // };
// template <int Ep, int ...Indices> // template <int Ep, int ...Indices>
// struct make_indices_imp<Ep, tuple_indices<Indices...>, Ep> { // struct make_indices_imp<Ep, tuple_indices<Indices...>, Ep> {
// typedef tuple_indices<Indices...> type; // typedef tuple_indices<Indices...> type;
// }; // };
@ -7492,7 +7491,7 @@ public class AST2TemplateTests extends AST2TestBase {
public void testVariadicTemplatesNPE_401743() throws Exception { public void testVariadicTemplatesNPE_401743() throws Exception {
parseAndCheckBindings(); parseAndCheckBindings();
} }
// template <typename T> // template <typename T>
// struct A {}; // struct A {};
// //
@ -7512,7 +7511,7 @@ public class AST2TemplateTests extends AST2TestBase {
public void testRegression_401743a() throws Exception { public void testRegression_401743a() throws Exception {
parseAndCheckBindings(); parseAndCheckBindings();
} }
// template <typename T> // template <typename T>
// struct A {}; // struct A {};
// //
@ -7534,7 +7533,7 @@ public class AST2TemplateTests extends AST2TestBase {
public void testRegression_401743b() throws Exception { public void testRegression_401743b() throws Exception {
parseAndCheckBindings(); parseAndCheckBindings();
} }
// template <typename T> // template <typename T>
// void foo(T t) { // void foo(T t) {
// bar(t); // bar(t);
@ -7542,7 +7541,7 @@ public class AST2TemplateTests extends AST2TestBase {
public void testUnqualifiedFunctionCallInTemplate_402498a() throws Exception { public void testUnqualifiedFunctionCallInTemplate_402498a() throws Exception {
parseAndCheckBindings(); parseAndCheckBindings();
} }
// template <typename T> // template <typename T>
// auto foo(T t) -> decltype(bar(t)); // auto foo(T t) -> decltype(bar(t));
// //
@ -7557,7 +7556,7 @@ public class AST2TemplateTests extends AST2TestBase {
public void testUnqualifiedFunctionCallInTemplate_402498b() throws Exception { public void testUnqualifiedFunctionCallInTemplate_402498b() throws Exception {
new BindingAssertionHelper(getAboveComment(), true).assertVariableType("x", CommonTypes.int_); new BindingAssertionHelper(getAboveComment(), true).assertVariableType("x", CommonTypes.int_);
} }
// template <typename T> // template <typename T>
// auto foo(T t) -> decltype(bar(t)); // auto foo(T t) -> decltype(bar(t));
// //
@ -7579,9 +7578,9 @@ public class AST2TemplateTests extends AST2TestBase {
// That's another bug for another day. // That's another bug for another day.
assertFalse(x.getType().isSameType(CommonTypes.int_)); assertFalse(x.getType().isSameType(CommonTypes.int_));
} }
// template <typename> // template <typename>
// struct no_type {}; // struct no_type {};
// //
// struct type {}; // struct type {};
// //

View file

@ -313,8 +313,8 @@ public class CPPSemantics {
IASTNode lookupPoint = data.getLookupPoint(); IASTNode lookupPoint = data.getLookupPoint();
if (binding == null && data.checkClassContainingFriend()) { if (binding == null && data.checkClassContainingFriend()) {
// 3.4.1-10 if we don't find a name used in a friend declaration in the member declaration's class // 3.4.1-10 If we don't find a name used in a friend declaration in the member
// we should look in the class granting friendship // declaration's class, we should look in the class granting friendship.
IASTNode parent = lookupName.getParent(); IASTNode parent = lookupName.getParent();
while (parent != null && !(parent instanceof ICPPASTCompositeTypeSpecifier)) while (parent != null && !(parent instanceof ICPPASTCompositeTypeSpecifier))
parent = parent.getParent(); parent = parent.getParent();
@ -329,7 +329,7 @@ public class CPPSemantics {
} }
} }
// Explicit type conversion in functional notation // Explicit type conversion in functional notation.
if (binding instanceof ICPPClassTemplate && lookupName instanceof ICPPASTTemplateId) { if (binding instanceof ICPPClassTemplate && lookupName instanceof ICPPASTTemplateId) {
final IASTNode parent = lookupName.getParent(); final IASTNode parent = lookupName.getParent();
if (parent instanceof IASTIdExpression && if (parent instanceof IASTIdExpression &&
@ -339,8 +339,9 @@ public class CPPSemantics {
} }
/* 14.6.1-1: /* 14.6.1-1:
* Within the scope of a class template, when the name of the template is neither qualified nor * Within the scope of a class template, when the name of the template is neither qualified
* followed by <, it is equivalent to the name followed by the template parameters enclosed in <>. * nor followed by <, it is equivalent to the name followed by the template arguments
* enclosed in <>.
*/ */
if (binding instanceof ICPPClassTemplate if (binding instanceof ICPPClassTemplate
&& !(binding instanceof ICPPClassSpecialization) && !(binding instanceof ICPPClassSpecialization)
@ -361,7 +362,7 @@ public class CPPSemantics {
while (node != null && !ok) { while (node != null && !ok) {
if (node instanceof ICPPASTTemplateId || if (node instanceof ICPPASTTemplateId ||
node instanceof ICPPASTTemplatedTypeTemplateParameter) { node instanceof ICPPASTTemplatedTypeTemplateParameter) {
ok= true; // can be argument or default-value for template template parameter ok= true; // Can be argument or default-value for template template parameter
break; break;
} else if (node instanceof IASTElaboratedTypeSpecifier) { } else if (node instanceof IASTElaboratedTypeSpecifier) {
IASTNode parent= node.getParent(); IASTNode parent= node.getParent();
@ -369,7 +370,7 @@ public class CPPSemantics {
IASTDeclSpecifier declspec = ((IASTSimpleDeclaration) parent).getDeclSpecifier(); IASTDeclSpecifier declspec = ((IASTSimpleDeclaration) parent).getDeclSpecifier();
if (declspec instanceof ICPPASTDeclSpecifier) { if (declspec instanceof ICPPASTDeclSpecifier) {
if (((ICPPASTDeclSpecifier) declspec).isFriend()) { if (((ICPPASTDeclSpecifier) declspec).isFriend()) {
ok= true; // a friend class template declarations uses resolution. ok= true; // A friend class template declarations uses resolution.
break; break;
} }
} }
@ -448,7 +449,8 @@ public class CPPSemantics {
} }
} }
// if the lookup in base-classes ran into a deferred instance, use the computed unknown binding. // If the lookup in base-classes ran into a deferred instance, use the computed unknown
// binding.
final ASTNodeProperty namePropertyInParent = name.getPropertyInParent(); final ASTNodeProperty namePropertyInParent = name.getPropertyInParent();
if (binding == null && data.skippedScope != null) { if (binding == null && data.skippedScope != null) {
if (data.hasFunctionArguments()) { if (data.hasFunctionArguments()) {
@ -468,11 +470,11 @@ public class CPPSemantics {
IASTNode parent = name.getParent().getParent(); IASTNode parent = name.getParent().getParent();
if (parent instanceof IASTTypeId && parent.getPropertyInParent() == ICPPASTTemplateId.TEMPLATE_ID_ARGUMENT) { if (parent instanceof IASTTypeId && parent.getPropertyInParent() == ICPPASTTemplateId.TEMPLATE_ID_ARGUMENT) {
if (!(binding instanceof IType)) { if (!(binding instanceof IType)) {
// a type id needs to hold a type // A type id needs to hold a type.
binding = new ProblemBinding(lookupName, lookupPoint, binding = new ProblemBinding(lookupName, lookupPoint,
IProblemBinding.SEMANTIC_INVALID_TYPE, data.getFoundBindings()); IProblemBinding.SEMANTIC_INVALID_TYPE, data.getFoundBindings());
} }
// don't create a problem here // Don't create a problem here.
} else { } else {
binding = new ProblemBinding(lookupName, lookupPoint, binding = new ProblemBinding(lookupName, lookupPoint,
IProblemBinding.SEMANTIC_INVALID_TYPE, data.getFoundBindings()); IProblemBinding.SEMANTIC_INVALID_TYPE, data.getFoundBindings());
@ -519,8 +521,8 @@ public class CPPSemantics {
} }
// If this is the unqualified name of a function in a function call in a template and some // If this is the unqualified name of a function in a function call in a template and some
// of the function arguments are dependent, the name could be resolved via argument-dependent // of the function arguments are dependent, the name could be resolved via
// lookup at the point of instantiation. // argument-dependent lookup at the point of instantiation.
if (binding == null) { if (binding == null) {
if (!data.qualified && data.isFunctionCall() && CPPTemplates.containsDependentType(data.getFunctionArgumentTypes())) { if (!data.qualified && data.isFunctionCall() && CPPTemplates.containsDependentType(data.getFunctionArgumentTypes())) {
binding = CPPDeferredFunction.createForName(lookupName.getSimpleID()); binding = CPPDeferredFunction.createForName(lookupName.getSimpleID());
@ -564,8 +566,8 @@ public class CPPSemantics {
public static void doKoenigLookup(LookupData data) throws DOMException { public static void doKoenigLookup(LookupData data) throws DOMException {
data.ignoreUsingDirectives = true; data.ignoreUsingDirectives = true;
// Set 'qualified' to true for the duration of this function call // Set 'qualified' to true for the duration of this function call so the calls to lookup()
// so the calls to lookup() don't ascend into enclosing scopes. // don't ascend into enclosing scopes.
boolean originalQualified = data.qualified; boolean originalQualified = data.qualified;
data.qualified = true; data.qualified = true;
Set<ICPPFunction> friendFns = new HashSet<ICPPFunction>(2); Set<ICPPFunction> friendFns = new HashSet<ICPPFunction>(2);
@ -580,7 +582,7 @@ public class CPPSemantics {
} }
static IBinding checkDeclSpecifier(IBinding binding, IASTName name, IASTNode decl) { static IBinding checkDeclSpecifier(IBinding binding, IASTName name, IASTNode decl) {
// check for empty declaration specifiers // Check for empty declaration specifiers.
if (!isCtorOrConversionOperator(binding)) { if (!isCtorOrConversionOperator(binding)) {
IASTDeclSpecifier declspec= null; IASTDeclSpecifier declspec= null;
if (decl instanceof IASTSimpleDeclaration) { if (decl instanceof IASTSimpleDeclaration) {
@ -692,9 +694,9 @@ public class CPPSemantics {
if (CharArrayUtils.equals(CPPVisitor.BEGIN, simpleID) || CharArrayUtils.equals(CPPVisitor.END, simpleID)) { if (CharArrayUtils.equals(CPPVisitor.BEGIN, simpleID) || CharArrayUtils.equals(CPPVisitor.END, simpleID)) {
IASTNode parent = lookupName.getParent(); // id-expression IASTNode parent = lookupName.getParent(); // id-expression
if (parent != null) if (parent != null)
parent= parent.getParent(); // function call parent= parent.getParent(); // function call
if (parent != null) if (parent != null)
parent= parent.getParent(); // the loop parent= parent.getParent(); // the loop
if (parent instanceof ICPPASTRangeBasedForStatement) { if (parent instanceof ICPPASTRangeBasedForStatement) {
IBinding[] std= parent.getTranslationUnit().getScope().find(CPPVisitor.STD); IBinding[] std= parent.getTranslationUnit().getScope().find(CPPVisitor.STD);
for (IBinding binding : std) { for (IBinding binding : std) {
@ -712,7 +714,8 @@ public class CPPSemantics {
private static void getAssociatedScopes(IType t, Set<ICPPNamespaceScope> namespaces, private static void getAssociatedScopes(IType t, Set<ICPPNamespaceScope> namespaces,
Set<ICPPFunction> friendFns, ObjectSet<IType> handled, CPPASTTranslationUnit tu) throws DOMException { Set<ICPPFunction> friendFns, ObjectSet<IType> handled, CPPASTTranslationUnit tu) throws DOMException {
t = getNestedType(t, TDEF | CVTYPE | PTR | ARRAY | REF); t = getNestedType(t, TDEF | CVTYPE | PTR | ARRAY | REF);
// No point getting namespaces associated with a dependent type - we don't know what they are yet. // No point getting namespaces associated with a dependent type - we don't know what they
// are yet.
if (CPPTemplates.isDependentType(t)) if (CPPTemplates.isDependentType(t))
return; return;
if (t instanceof IBinding) { if (t instanceof IBinding) {