From c05531872676b0b8090ce51e58d2182d68d8e8af Mon Sep 17 00:00:00 2001
From: Sergey Prigogin <eclipse.sprigogin@gmail.com>
Date: Tue, 2 Apr 2013 18:40:45 -0700
Subject: [PATCH] Cosmetics.

---
 .../parser/tests/ast2/AST2TemplateTests.java  | 51 +++++++++----------
 .../parser/cpp/semantics/CPPSemantics.java    | 39 +++++++-------
 2 files changed, 46 insertions(+), 44 deletions(-)

diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java
index 3dc6e481ff0..1f161df79cd 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java
@@ -5880,7 +5880,7 @@ public class AST2TemplateTests extends AST2TestBase {
 	//
 	//	template <class Container>
 	//	auto begin1(Container cont) -> decltype(cont.begin());
-	//	
+	//
 	//	template <class Container>
 	//	auto begin2(Container& cont) -> decltype(cont.begin());
 	//
@@ -5892,7 +5892,7 @@ public class AST2TemplateTests extends AST2TestBase {
 		helper.assertVariableType("x1", CommonTypes.pointerToInt);
 		helper.assertVariableType("x2", CommonTypes.pointerToInt);
 	}
-	
+
 	//	struct vector {
 	//	    int* begin();
 	//	    const int* begin() const;
@@ -5912,7 +5912,7 @@ public class AST2TemplateTests extends AST2TestBase {
 	public void testResolvingAutoTypeWithDependentExpression_402409b() throws Exception {
 		parseAndCheckBindings();
 	}
-	
+
 	//	void foo(int, int);
 	//	template <typename... Args> void bar(Args... args) {
 	//	    foo(1,2,args...);
@@ -6212,7 +6212,7 @@ public class AST2TemplateTests extends AST2TestBase {
 	public void testPointerToMemberAsDependentExpression_391001() throws Exception {
 		parseAndCheckBindings(getAboveComment(), CPP, true);
 	}
-	
+
 	//	template<typename>
 	//	struct A {
 	//	    char x;
@@ -6999,11 +6999,11 @@ public class AST2TemplateTests extends AST2TestBase {
 	public void testSFINAEInDefaultArgument() throws Exception {
 		parseAndCheckBindings();
 	}
-	
+
 	//	typedef char (&no_tag)[1];
 	//	typedef char (&yes_tag)[2];
 	//
-	//	template <typename T> 
+	//	template <typename T>
 	//	struct type_wrapper {};
 	//
 	//	template <typename T>
@@ -7024,7 +7024,7 @@ public class AST2TemplateTests extends AST2TestBase {
 		assertNotNull(val);
 		assertEquals(0 /* false */, val.longValue());
 	}
-	
+
 	//	template <typename>
 	//	struct M {
 	//	    template <typename... Args>
@@ -7140,7 +7140,7 @@ public class AST2TemplateTests extends AST2TestBase {
 	}
 
 	//	template <int...> struct A {};
-	//	template <int... I> void foo(A<I...>); 
+	//	template <int... I> void foo(A<I...>);
 	//	int main() {
 	//		foo(A<0>());
 	//	}
@@ -7160,10 +7160,10 @@ public class AST2TemplateTests extends AST2TestBase {
 	//	struct contains_foo {
 	//	    static const bool value = ice_or<is_foo<Args>::value...>::value;
 	//	};
-	//	template <bool> 
+	//	template <bool>
 	//	struct meta;
 	//	struct S { void bar(); };
-	//	template <> 
+	//	template <>
 	//	struct meta<false> {
 	//	    typedef S type;
 	//	};
@@ -7204,7 +7204,7 @@ public class AST2TemplateTests extends AST2TestBase {
 	public void testClassTemplateSpecializationPartialOrdering_398044b() throws Exception {
 		parseAndCheckBindings();
 	}
-	
+
 	//	template <typename T>
 	//	struct waldo {
 	//	    typedef int type;
@@ -7217,7 +7217,7 @@ public class AST2TemplateTests extends AST2TestBase {
 	public void testPartialSpecializationForVarargFunctionType_402807() throws Exception {
 		parseAndCheckBindings();
 	}
-	
+
 	//	template <typename>
 	//	struct meta {
 	//	    static const bool value = 1;
@@ -7241,7 +7241,7 @@ public class AST2TemplateTests extends AST2TestBase {
 	public void testRegression_399142() throws Exception {
 		parseAndCheckBindings();
 	}
-	
+
 	//	template <class T>
 	//	struct A {
 	//	    struct impl {
@@ -7257,7 +7257,7 @@ public class AST2TemplateTests extends AST2TestBase {
 	public void testDependentExpressionInvolvingFieldInNestedClass_399362() throws Exception {
 		parseAndCheckBindings();
 	}
-	
+
 	//    template <typename _Tp>
 	//    struct remove_reference {
 	//        typedef _Tp type;
@@ -7357,7 +7357,7 @@ public class AST2TemplateTests extends AST2TestBase {
     public void testNameLookupInDependentExpression_399829b() throws Exception {
         parseAndCheckBindings();
     }
-    
+
 	//    template <bool> int assertion_failed(void*);
 	//    struct assert_ {};
 	//    assert_ arg;
@@ -7402,7 +7402,6 @@ public class AST2TemplateTests extends AST2TestBase {
 		BindingAssertionHelper helper = new BindingAssertionHelper(getAboveComment(), true);
 		helper.assertProblem("bind(s, 0, foo)", "bind");
     }
-	
 
 	//	template<typename T>
 	//	T forward(T);
@@ -7432,7 +7431,7 @@ public class AST2TemplateTests extends AST2TestBase {
 	public void testVariadicNonTypeTemplateParameter_401142() throws Exception {
 		parseAndCheckBindings();
 	}
-	
+
 	//	template <bool... Args>
 	//	struct ice_or;
 	//	template <>
@@ -7454,7 +7453,7 @@ public class AST2TemplateTests extends AST2TestBase {
 	public void testVariadicNonTypeTemplateParameter_401400() throws Exception {
 		parseAndCheckBindings();
 	}
-	
+
 	//	template <typename... Args>
 	//	struct foo {
 	//		static constexpr int i = sizeof...(Args);
@@ -7475,7 +7474,7 @@ public class AST2TemplateTests extends AST2TestBase {
 	//	struct make_indices_imp<Sp, tuple_indices<Indices...>, Ep> {
 	//	    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> {
 	//	    typedef tuple_indices<Indices...> type;
 	//	};
@@ -7492,7 +7491,7 @@ public class AST2TemplateTests extends AST2TestBase {
 	public void testVariadicTemplatesNPE_401743() throws Exception {
 		parseAndCheckBindings();
 	}
-	
+
 	//	template <typename T>
 	//	struct A {};
 	//
@@ -7512,7 +7511,7 @@ public class AST2TemplateTests extends AST2TestBase {
 	public void testRegression_401743a() throws Exception {
 		parseAndCheckBindings();
 	}
-	
+
 	//	template <typename T>
 	//	struct A {};
 	//
@@ -7534,7 +7533,7 @@ public class AST2TemplateTests extends AST2TestBase {
 	public void testRegression_401743b() throws Exception {
 		parseAndCheckBindings();
 	}
-	
+
 	//	template <typename T>
 	//	void foo(T t) {
 	//	    bar(t);
@@ -7542,7 +7541,7 @@ public class AST2TemplateTests extends AST2TestBase {
 	public void testUnqualifiedFunctionCallInTemplate_402498a() throws Exception {
 		parseAndCheckBindings();
 	}
-	
+
 	//	template <typename T>
 	//	auto foo(T t) -> decltype(bar(t));
 	//
@@ -7557,7 +7556,7 @@ public class AST2TemplateTests extends AST2TestBase {
 	public void testUnqualifiedFunctionCallInTemplate_402498b() throws Exception {
 		new BindingAssertionHelper(getAboveComment(), true).assertVariableType("x", CommonTypes.int_);
 	}
-	
+
 	//	template <typename T>
 	//	auto foo(T t) -> decltype(bar(t));
 	//
@@ -7579,9 +7578,9 @@ public class AST2TemplateTests extends AST2TestBase {
 		// That's another bug for another day.
 		assertFalse(x.getType().isSameType(CommonTypes.int_));
 	}
-	
+
 	//	template <typename>
-	//	struct no_type {}; 
+	//	struct no_type {};
 	//
 	//	struct type {};
 	//
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java
index b744feffa86..e1d0d3c83ee 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java
@@ -313,8 +313,8 @@ public class CPPSemantics {
 		IASTNode lookupPoint = data.getLookupPoint();
 
         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
-        	// we should look in the class granting friendship
+        	// 3.4.1-10 If we don't find a name used in a friend declaration in the member
+        	// declaration's class, we should look in the class granting friendship.
 			IASTNode parent = lookupName.getParent();
         	while (parent != null && !(parent instanceof ICPPASTCompositeTypeSpecifier))
         		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) {
 			final IASTNode parent = lookupName.getParent();
 			if (parent instanceof IASTIdExpression &&
@@ -339,8 +339,9 @@ public class CPPSemantics {
 		}
 
         /* 14.6.1-1:
-         * Within the scope of a class template, when the name of the template is neither qualified nor
-         * followed by <, it is equivalent to the name followed by the template parameters enclosed in <>.
+         * Within the scope of a class template, when the name of the template is neither qualified
+         * nor followed by <, it is equivalent to the name followed by the template arguments
+         * enclosed in <>.
          */
 		if (binding instanceof ICPPClassTemplate
 				&& !(binding instanceof ICPPClassSpecialization)
@@ -361,7 +362,7 @@ public class CPPSemantics {
 					while (node != null && !ok) {
 						if (node instanceof ICPPASTTemplateId ||
 								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;
 						} else if (node instanceof IASTElaboratedTypeSpecifier) {
 							IASTNode parent= node.getParent();
@@ -369,7 +370,7 @@ public class CPPSemantics {
 								IASTDeclSpecifier declspec = ((IASTSimpleDeclaration) parent).getDeclSpecifier();
 								if (declspec instanceof ICPPASTDeclSpecifier) {
 									if (((ICPPASTDeclSpecifier) declspec).isFriend()) {
-										ok= true;  // a friend class template declarations uses resolution.
+										ok= true;  // A friend class template declarations uses resolution.
 										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();
 		if (binding == null && data.skippedScope != null) {
 			if (data.hasFunctionArguments()) {
@@ -468,11 +470,11 @@ public class CPPSemantics {
 	        		IASTNode parent = name.getParent().getParent();
 	        		if (parent instanceof IASTTypeId && parent.getPropertyInParent() == ICPPASTTemplateId.TEMPLATE_ID_ARGUMENT) {
 	        			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,
 	        						IProblemBinding.SEMANTIC_INVALID_TYPE, data.getFoundBindings());
 	        			}
-	        			// don't create a problem here
+	        			// Don't create a problem here.
 	        		} else {
 	        			binding = new ProblemBinding(lookupName, lookupPoint,
 	        					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
-		// of the function arguments are dependent, the name could be resolved via argument-dependent
-		// lookup at the point of instantiation.
+		// of the function arguments are dependent, the name could be resolved via
+		// argument-dependent lookup at the point of instantiation.
 		if (binding == null) {
 			if (!data.qualified && data.isFunctionCall() && CPPTemplates.containsDependentType(data.getFunctionArgumentTypes())) {
 				binding = CPPDeferredFunction.createForName(lookupName.getSimpleID());
@@ -564,8 +566,8 @@ public class CPPSemantics {
 
 	public static void doKoenigLookup(LookupData data) throws DOMException {
 		data.ignoreUsingDirectives = true;
-		// Set 'qualified' to true for the duration of this function call
-		// so the calls to lookup() don't ascend into enclosing scopes.
+		// Set 'qualified' to true for the duration of this function call so the calls to lookup()
+		// don't ascend into enclosing scopes.
 		boolean originalQualified = data.qualified;
 		data.qualified = true;
         Set<ICPPFunction> friendFns = new HashSet<ICPPFunction>(2);
@@ -580,7 +582,7 @@ public class CPPSemantics {
 	}
 
 	static IBinding checkDeclSpecifier(IBinding binding, IASTName name, IASTNode decl) {
-		// check for empty declaration specifiers
+		// Check for empty declaration specifiers.
 		if (!isCtorOrConversionOperator(binding)) {
 			IASTDeclSpecifier declspec= null;
 			if (decl instanceof IASTSimpleDeclaration) {
@@ -692,9 +694,9 @@ public class CPPSemantics {
 	        if (CharArrayUtils.equals(CPPVisitor.BEGIN, simpleID) || CharArrayUtils.equals(CPPVisitor.END, simpleID)) {
 	        	IASTNode parent = lookupName.getParent();     // id-expression
 	        	if (parent != null)
-	        		parent= parent.getParent();     			// function call
+	        		parent= parent.getParent();     		  // function call
 	        	if (parent != null)
-	        		parent= parent.getParent();     			// the loop
+	        		parent= parent.getParent();     		  // the loop
 	        	if (parent instanceof ICPPASTRangeBasedForStatement) {
 	        		IBinding[] std= parent.getTranslationUnit().getScope().find(CPPVisitor.STD);
 	        		for (IBinding binding : std) {
@@ -712,7 +714,8 @@ public class CPPSemantics {
     private static void getAssociatedScopes(IType t, Set<ICPPNamespaceScope> namespaces,
     		Set<ICPPFunction> friendFns, ObjectSet<IType> handled, CPPASTTranslationUnit tu) throws DOMException {
         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))
         	return;
     	if (t instanceof IBinding) {