From 3548fdb678052f34d8644d4bc8653c82773b1f1c Mon Sep 17 00:00:00 2001 From: Sergey Prigogin Date: Thu, 8 Nov 2012 14:04:50 -0800 Subject: [PATCH] Revert "Preservation of typedefs in template arguments." This reverts commit 8ec3ab2f9413729cf1878fe639f2556affd5c8d3. --- .../core/parser/tests/ast2/AST2CPPTests.java | 61 +++---------------- .../eclipse/cdt/core/dom/ast/ASTTypeUtil.java | 3 +- .../dom/ast/cpp/ICPPTemplateArgument.java | 17 ++---- .../cpp/CPPTemplateNonTypeArgument.java | 5 -- .../parser/cpp/CPPTemplateTypeArgument.java | 16 +---- .../parser/cpp/semantics/CPPTemplates.java | 2 +- .../core/dom/parser/cpp/semantics/EvalID.java | 4 +- .../parser/cpp/semantics/SemanticUtil.java | 2 +- .../semantics/TemplateArgumentDeduction.java | 5 +- .../eclipse/cdt/internal/core/pdom/PDOM.java | 7 +-- .../core/pdom/db/TypeMarshalBuffer.java | 5 +- .../text/contentassist2/CompletionTests.java | 4 +- 12 files changed, 27 insertions(+), 104 deletions(-) diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java index f48f742fc2d..8b8da5697d4 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java @@ -4795,63 +4795,20 @@ public class AST2CPPTests extends AST2BaseTest { assertEquals("string", ((ITypedef) s3.getType()).getName()); } - // template - // struct vector { - // typedef T* const_iterator; - // const_iterator begin() const; - // }; - // - // typedef int Element; - // - // void test(const vector& v) { + // template + // struct vector { + // typedef T* const_iterator; + // const_iterator begin() const; + // }; + // + // void test(const vector& v) { // auto it = v.begin(); // } - public void testTypedefPreservation_380498_2() throws Exception { + public void testTypedefPreservation_380498_2() throws Exception { BindingAssertionHelper ba= getAssertionHelper(); ICPPVariable it = ba.assertNonProblem("it =", "it", ICPPVariable.class); assertTrue(it.getType() instanceof ITypedef); - assertEquals("vector::const_iterator", ASTTypeUtil.getType(it.getType(), false)); - } - - // template class char_traits {}; - // template > class basic_string {}; - // - // template - // struct iterator_traits { - // typedef typename _Iterator::reference reference; - // }; - // - // template - // struct iterator_traits<_Tp*> { - // typedef _Tp& reference; - // }; - // - // template - // struct normal_iterator { - // typedef iterator_traits<_Iterator> traits_type; - // typedef typename traits_type::reference reference; - // reference operator*() const; - // }; - // - // template struct vector { - // typedef T* pointer; - // typedef normal_iterator iterator; - // iterator begin(); - // iterator end(); - // }; - // - // typedef basic_string string; - // - // void test() { - // vector v; - // for (auto s : v) { - // } - // } - public void testTypedefPreservation_380498_3() throws Exception { - BindingAssertionHelper ba= getAssertionHelper(); - ICPPVariable s = ba.assertNonProblem("s :", "s", ICPPVariable.class); - assertTrue(s.getType() instanceof ITypedef); - assertEquals("string", ASTTypeUtil.getType(s.getType(), false)); + assertEquals("vector::const_iterator", ASTTypeUtil.getType(it.getType(), false)); } // int f() { diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ASTTypeUtil.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ASTTypeUtil.java index 3f62ddf6e3d..325295bd82d 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ASTTypeUtil.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ASTTypeUtil.java @@ -183,8 +183,7 @@ public class ASTTypeUtil { if (val != null) { buf.append(val.getSignature()); } else { - IType type = normalize ? arg.getTypeValue() : arg.getOriginalTypeValue(); - appendType(type, normalize, buf); + appendType(arg.getTypeValue(), normalize, buf); } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPTemplateArgument.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPTemplateArgument.java index 0f8fb9acff5..a4aa4fb9c77 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPTemplateArgument.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPTemplateArgument.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2012 Wind River Systems, Inc. and others. + * Copyright (c) 2008, 2009 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -7,7 +7,6 @@ * * Contributors: * Markus Schorn - initial API and implementation - * Sergey Prigogin (Google) *******************************************************************************/ package org.eclipse.cdt.core.dom.ast.cpp; @@ -37,19 +36,11 @@ public interface ICPPTemplateArgument { boolean isTypeValue(); /** - * If this is a type value (suitable for a template type and template template parameters), - * the type used as a value is returned. - * For non-type values, null is returned. - * The returned type has all typedefs resolved. + * If this is a type value (suitable for a template type and template template parameters), + * the type used as a value is returned. + * For non-type values, null is returned. */ IType getTypeValue(); - - /** - * Similar to {@link #getTypeValue()} but returns the original type value before typedef - * resolution. - * @noreference This method is not intended to be referenced by clients. - */ - IType getOriginalTypeValue(); /** * If this is a non-type value (suitable for a template non-type parameters), diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateNonTypeArgument.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateNonTypeArgument.java index 9e6e6e080c7..3c095d5db00 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateNonTypeArgument.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateNonTypeArgument.java @@ -41,11 +41,6 @@ public class CPPTemplateNonTypeArgument implements ICPPTemplateArgument { return false; } - @Override - public IType getOriginalTypeValue() { - return null; - } - @Override public boolean isNonTypeValue() { return true; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateTypeArgument.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateTypeArgument.java index f5d5cd74919..7ec0f62f798 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateTypeArgument.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateTypeArgument.java @@ -22,17 +22,10 @@ import org.eclipse.core.runtime.Assert; */ public class CPPTemplateTypeArgument implements ICPPTemplateArgument { private final IType fType; - private final IType fOriginalType; public CPPTemplateTypeArgument(IType type) { - this(type, type); - } - - public CPPTemplateTypeArgument(IType simplifiedType, IType originalType) { - Assert.isNotNull(simplifiedType); - Assert.isNotNull(originalType); - fType= simplifiedType; - fOriginalType= originalType; + Assert.isNotNull(type); + fType= type; } @Override @@ -50,11 +43,6 @@ public class CPPTemplateTypeArgument implements ICPPTemplateArgument { return fType; } - @Override - public IType getOriginalTypeValue() { - return fOriginalType; - } - @Override public IValue getNonTypeValue() { return null; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPTemplates.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPTemplates.java index 6272376d8cb..122590d4731 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPTemplates.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPTemplates.java @@ -1162,7 +1162,7 @@ public class CPPTemplates { } if (arg != null) { - IType t= arg.getOriginalTypeValue(); + IType t= arg.getTypeValue(); if (t != null) return t; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalID.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalID.java index f16254948db..9d1cf787526 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalID.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalID.java @@ -13,8 +13,6 @@ package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics; import static org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory.LVALUE; import static org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory.PRVALUE; -import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.TDEF; -import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.getNestedType; import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IASTExpression; @@ -296,7 +294,7 @@ public class EvalID extends CPPEvaluation { } else if (nameOwner instanceof IType) { IType type = CPPTemplates.instantiateType((IType) nameOwner, tpMap, packOffset, within, point); if (type instanceof IBinding) - nameOwner = (IBinding) getNestedType(type, TDEF); + nameOwner = (IBinding) type; } if (fieldOwner instanceof IProblemBinding || nameOwner instanceof IProblemBinding) diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/SemanticUtil.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/SemanticUtil.java index 706a45dcb25..3d9dadf4b01 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/SemanticUtil.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/SemanticUtil.java @@ -512,7 +512,7 @@ public class SemanticUtil { final IType type= arg.getTypeValue(); final IType newType= getSimplifiedType(type); if (newType != type) { - return new CPPTemplateTypeArgument(newType, arg.getOriginalTypeValue()); + return new CPPTemplateTypeArgument(newType); } } return arg; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/TemplateArgumentDeduction.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/TemplateArgumentDeduction.java index c494e701305..14d895b84ae 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/TemplateArgumentDeduction.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/TemplateArgumentDeduction.java @@ -665,12 +665,11 @@ public class TemplateArgumentDeduction { return tval.equals(sval); } - return fromType(p.getTypeValue(), a.getOriginalTypeValue(), false, point); + return fromType(p.getTypeValue(), a.getTypeValue(), false, point); } private boolean fromType(IType p, IType a, boolean allowCVQConversion, IASTNode point) throws DOMException { while (p != null) { - IType argumentTypeBeforeTypedefResolution = a; while (a instanceof ITypedef) a = ((ITypedef) a).getType(); if (p instanceof IBasicType) { @@ -763,7 +762,7 @@ public class TemplateArgumentDeduction { } if (a == null) return false; - return deduce(((ICPPTemplateParameter) p).getParameterID(), new CPPTemplateTypeArgument(a, argumentTypeBeforeTypedefResolution)); + return deduce(((ICPPTemplateParameter)p).getParameterID(), new CPPTemplateTypeArgument(a)); } else if (p instanceof ICPPTemplateInstance) { if (!(a instanceof ICPPTemplateInstance)) return false; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOM.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOM.java index ad62367afd9..ba33a50e978 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOM.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOM.java @@ -219,11 +219,10 @@ public class PDOM extends PlatformObject implements IPDOM { * #125.0# - Indexes for unresolved includes and files indexed with I/O errors. <> * 126.0 - Dependent expressions, bug 299911. * 127.0 - Explicit virtual overrides, bug 380623. - * 128.0 - Extended CPPTemplateTypeArgument to include the original type, bug 392278. */ - private static final int MIN_SUPPORTED_VERSION= version(128, 0); - private static final int MAX_SUPPORTED_VERSION= version(128, Short.MAX_VALUE); - private static final int DEFAULT_VERSION = version(128, 0); + private static final int MIN_SUPPORTED_VERSION= version(127, 0); + private static final int MAX_SUPPORTED_VERSION= version(127, Short.MAX_VALUE); + private static final int DEFAULT_VERSION = version(127, 0); private static int version(int major, int minor) { return (major << 16) + minor; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/db/TypeMarshalBuffer.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/db/TypeMarshalBuffer.java index 0a1b22fba04..b3e7656fca4 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/db/TypeMarshalBuffer.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/db/TypeMarshalBuffer.java @@ -194,7 +194,6 @@ public class TypeMarshalBuffer implements ITypeMarshalBuffer { ((CPPTemplateNonTypeArgument) arg).getEvaluation().marshal(this, true); } else { marshalType(arg.getTypeValue()); - marshalType(arg.getOriginalTypeValue()); } } @@ -205,9 +204,7 @@ public class TypeMarshalBuffer implements ITypeMarshalBuffer { return new CPPTemplateNonTypeArgument((ICPPEvaluation) unmarshalEvaluation()); } else { fPos--; - IType type = unmarshalType(); - IType originalType = unmarshalType(); - return new CPPTemplateTypeArgument(type, originalType); + return new CPPTemplateTypeArgument(unmarshalType()); } } diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTests.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTests.java index f41331227f9..bc27e46dee4 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTests.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2012 Wind River Systems, Inc. and others. + * Copyright (c) 2006, 2011 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -1329,7 +1329,7 @@ public class CompletionTests extends AbstractContentAssistTest { // v.push_back(/*cursor*/); // } public void testTypedefSpecialization_Bug307818() throws Exception { - final String[] expected= { "push_back(const vector::value_type & value) : void" }; + final String[] expected= { "push_back(const vector::value_type & value) : void" }; assertParameterHint(expected); }