mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Revert "Preservation of typedefs in template arguments."
This reverts commit 8ec3ab2f94
.
This commit is contained in:
parent
d6ad63a4d9
commit
3548fdb678
12 changed files with 27 additions and 104 deletions
|
@ -4801,57 +4801,14 @@ public class AST2CPPTests extends AST2BaseTest {
|
|||
// const_iterator begin() const;
|
||||
// };
|
||||
//
|
||||
// typedef int Element;
|
||||
//
|
||||
// void test(const vector<Element>& v) {
|
||||
// void test(const vector<int>& v) {
|
||||
// auto it = v.begin();
|
||||
// }
|
||||
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<Element>::const_iterator", ASTTypeUtil.getType(it.getType(), false));
|
||||
}
|
||||
|
||||
// template <typename T> class char_traits {};
|
||||
// template <typename C, typename T = char_traits<C>> class basic_string {};
|
||||
//
|
||||
// template<typename _Iterator>
|
||||
// struct iterator_traits {
|
||||
// typedef typename _Iterator::reference reference;
|
||||
// };
|
||||
//
|
||||
// template<typename _Tp>
|
||||
// struct iterator_traits<_Tp*> {
|
||||
// typedef _Tp& reference;
|
||||
// };
|
||||
//
|
||||
// template<typename _Iterator, typename _Container>
|
||||
// struct normal_iterator {
|
||||
// typedef iterator_traits<_Iterator> traits_type;
|
||||
// typedef typename traits_type::reference reference;
|
||||
// reference operator*() const;
|
||||
// };
|
||||
//
|
||||
// template <typename T> struct vector {
|
||||
// typedef T* pointer;
|
||||
// typedef normal_iterator<pointer, vector> iterator;
|
||||
// iterator begin();
|
||||
// iterator end();
|
||||
// };
|
||||
//
|
||||
// typedef basic_string<char> string;
|
||||
//
|
||||
// void test() {
|
||||
// vector<string> 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<int>::const_iterator", ASTTypeUtil.getType(it.getType(), false));
|
||||
}
|
||||
|
||||
// int f() {
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
@ -40,17 +39,9 @@ public interface ICPPTemplateArgument {
|
|||
* 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, <code>null</code> is returned.
|
||||
* The returned type has all typedefs resolved.
|
||||
*/
|
||||
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),
|
||||
* the value is returned.
|
||||
|
|
|
@ -41,11 +41,6 @@ public class CPPTemplateNonTypeArgument implements ICPPTemplateArgument {
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IType getOriginalTypeValue() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNonTypeValue() {
|
||||
return true;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -1162,7 +1162,7 @@ public class CPPTemplates {
|
|||
}
|
||||
|
||||
if (arg != null) {
|
||||
IType t= arg.getOriginalTypeValue();
|
||||
IType t= arg.getTypeValue();
|
||||
if (t != null)
|
||||
return t;
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -219,11 +219,10 @@ public class PDOM extends PlatformObject implements IPDOM {
|
|||
* #125.0# - Indexes for unresolved includes and files indexed with I/O errors. <<CDT 8.1>>
|
||||
* 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;
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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<MyType>::value_type & value) : void" };
|
||||
final String[] expected= { "push_back(const vector<int>::value_type & value) : void" };
|
||||
assertParameterHint(expected);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue