Skip to main content
aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorMarco Stornelli2020-03-28 10:15:08 +0000
committerMarco Stornelli2020-04-01 06:31:07 +0000
commit703310dfa6a2e03993b269ecfaba2e001d72124d (patch)
tree00b76d0c7ed1f59ea25dda580968a1365b1a2388 /core
parent7458b960c98c40748897773bb255fe15eedcecde (diff)
downloadorg.eclipse.cdt-703310dfa6a2e03993b269ecfaba2e001d72124d.tar.gz
org.eclipse.cdt-703310dfa6a2e03993b269ecfaba2e001d72124d.tar.xz
org.eclipse.cdt-703310dfa6a2e03993b269ecfaba2e001d72124d.zip
Bug 534420 - Add support for nodiscard attribute for class types
Diffstat (limited to 'core')
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java75
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/ClassTests.java10
-rw-r--r--core/org.eclipse.cdt.core.tests/resources/pdomtests/classTests/class.cpp3
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPClassType.java7
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassSpecialization.java14
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassTemplate.java10
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassType.java15
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClosureType.java5
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPDeferredClassInstance.java5
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateTemplateParameter.java5
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateTemplateParameterSpecialization.java5
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUnknownMemberClass.java5
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPClassType.java5
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPTemplateTemplateParameter.java5
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOM.java7
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMASTAdapter.java5
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassSpecialization.java11
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassType.java19
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPTemplateTemplateParameter.java5
19 files changed, 212 insertions, 4 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 d27cea8328e..c7f0d1a7af5 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
@@ -145,15 +145,20 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPVariable;
import org.eclipse.cdt.core.dom.ast.cpp.SemanticQueries;
import org.eclipse.cdt.core.parser.IProblem;
import org.eclipse.cdt.core.parser.ParserLanguage;
+import org.eclipse.cdt.core.parser.util.AttributeUtil;
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTNameBase;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPBasicType;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPClassInstance;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPClassTemplate;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPClassTemplatePartialSpecialization;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPClassType;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPConstructor;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPFunctionType;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPMethod;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPPointerType;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPQualifierType;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPVariable;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ClassTypeHelper;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding;
import org.eclipse.cdt.internal.core.dom.parser.cpp.OverloadableOperator;
@@ -13426,4 +13431,74 @@ public class AST2CPPTests extends AST2CPPTestBase {
ICPPASTExpression f = helper.assertNode("f[] = \"waldo\"", "\"waldo\"");
assertTrue(e.getEvaluation().isEquivalentTo(f.getEvaluation()));
}
+
+ // struct Base {
+ // };
+ // struct [[nodiscard]] S : public Base {
+ // };
+ public void testNoDiscardClass_Bug534420() throws Exception {
+ String code = getAboveComment();
+ parseAndCheckBindings(code);
+
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
+
+ CPPClassType structBase = bh.assertNonProblem("Base {", 4);
+ assertFalse(structBase.isNoDiscard());
+ IASTNode baseDefinitionName = structBase.getDefinition();
+ IASTNode baseDefinition = baseDefinitionName.getParent();
+ assertInstance(baseDefinition, ICPPASTCompositeTypeSpecifier.class);
+ assertFalse(AttributeUtil.hasNodiscardAttribute(((ICPPASTCompositeTypeSpecifier) baseDefinition)));
+
+ CPPClassType structS = bh.assertNonProblem("S", 1);
+ assertTrue(structS.isNoDiscard());
+ IASTNode sDefinitionName = structS.getDefinition();
+ IASTNode sDefinition = sDefinitionName.getParent();
+ assertInstance(sDefinition, ICPPASTCompositeTypeSpecifier.class);
+ assertTrue(AttributeUtil.hasNodiscardAttribute(((ICPPASTCompositeTypeSpecifier) sDefinition)));
+ }
+
+ //template <typename T>
+ //struct Foo {};
+ //template <typename T>
+ //struct [[nodiscard]] Foo<T*> {};
+ //template <>
+ //struct [[nodiscard]] Foo<int> {};
+ //
+ //Foo<double> var1;
+ //Foo<int*> var2;
+ //Foo<int> var3;
+ public void testNoDiscardTemplateSpecialization_Bug534420() throws Exception {
+ String code = getAboveComment();
+ parseAndCheckBindings(code);
+
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
+
+ CPPClassTemplate structFoo = bh.assertNonProblem("Foo {", 3);
+ assertFalse(structFoo.isNoDiscard());
+ IASTNode fooDefinitionName = structFoo.getDefinition();
+ IASTNode fooDefinition = fooDefinitionName.getParent();
+ assertInstance(fooDefinition, ICPPASTCompositeTypeSpecifier.class);
+ assertFalse(AttributeUtil.hasNodiscardAttribute(((ICPPASTCompositeTypeSpecifier) fooDefinition)));
+
+ CPPClassTemplatePartialSpecialization structSpec = bh.assertNonProblem("Foo<T*> {", 7);
+ assertTrue(structSpec.isNoDiscard());
+ IASTNode specDefinitionName = structSpec.getDefinition();
+ IASTNode specDefinition = specDefinitionName.getParent();
+ assertInstance(specDefinition, ICPPASTCompositeTypeSpecifier.class);
+ assertTrue(AttributeUtil.hasNodiscardAttribute(((ICPPASTCompositeTypeSpecifier) specDefinition)));
+
+ CPPClassInstance structFullSpec = bh.assertNonProblem("Foo<int> {", 8);
+ assertTrue(structSpec.isNoDiscard());
+ IASTNode specFullDefinitionName = structFullSpec.getDefinition();
+ IASTNode specFullDefinition = specFullDefinitionName.getParent();
+ assertInstance(specFullDefinition, ICPPASTCompositeTypeSpecifier.class);
+ assertTrue(AttributeUtil.hasNodiscardAttribute(((ICPPASTCompositeTypeSpecifier) specFullDefinition)));
+
+ CPPVariable var1Base = bh.assertNonProblem("var1", 4);
+ CPPVariable var2Spec = bh.assertNonProblem("var2", 4);
+ CPPVariable var3Spec = bh.assertNonProblem("var3", 4);
+ assertFalse(((CPPClassInstance) var1Base.getType()).isNoDiscard());
+ assertTrue(((CPPClassInstance) var2Spec.getType()).isNoDiscard());
+ assertTrue(((CPPClassInstance) var3Spec.getType()).isNoDiscard());
+ }
}
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/ClassTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/ClassTests.java
index b698182cfc7..28de19d5a6f 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/ClassTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/ClassTests.java
@@ -244,4 +244,14 @@ public class ClassTests extends PDOMTestBase {
assertTrue(classBinding.isFinal());
}
+
+ public void testNoDiscardClass() throws Exception {
+ char[][] name = { "F".toCharArray() };
+ IBinding[] bindings = pdom.findBindings(name, IndexFilter.ALL, npm());
+ assertEquals(1, bindings.length);
+ assertInstance(bindings[0], ICPPClassType.class);
+ ICPPClassType classBinding = (ICPPClassType) bindings[0];
+
+ assertTrue(classBinding.isNoDiscard());
+ }
}
diff --git a/core/org.eclipse.cdt.core.tests/resources/pdomtests/classTests/class.cpp b/core/org.eclipse.cdt.core.tests/resources/pdomtests/classTests/class.cpp
index 6a606e8e3df..17c5fd0f009 100644
--- a/core/org.eclipse.cdt.core.tests/resources/pdomtests/classTests/class.cpp
+++ b/core/org.eclipse.cdt.core.tests/resources/pdomtests/classTests/class.cpp
@@ -35,3 +35,6 @@ class D {
class E final : public A {
};
+
+class [[nodiscard]] F : public A {
+};
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPClassType.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPClassType.java
index b9632bf3fd3..d11081a1690 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPClassType.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPClassType.java
@@ -137,4 +137,11 @@ public interface ICPPClassType extends ICompositeType, ICPPBinding {
* @since 5.5
*/
public int getVisibility(IBinding member);
+
+ /**
+ * Returns whether this type is declared 'nodiscard'.
+ *
+ * @since 6.12
+ */
+ public boolean isNoDiscard();
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassSpecialization.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassSpecialization.java
index 11b3070e16b..e9d866e4d9a 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassSpecialization.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassSpecialization.java
@@ -46,6 +46,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPUsingDeclaration;
+import org.eclipse.cdt.core.parser.util.AttributeUtil;
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
import org.eclipse.cdt.core.parser.util.ObjectMap;
import org.eclipse.cdt.internal.core.dom.parser.IRecursionResolvingBinding;
@@ -511,6 +512,19 @@ public class CPPClassSpecialization extends CPPSpecialization
}
@Override
+ public boolean isNoDiscard() {
+ ICPPASTCompositeTypeSpecifier typeSpecifier = getCompositeTypeSpecifier();
+ if (typeSpecifier != null) {
+ return AttributeUtil.hasNodiscardAttribute(typeSpecifier);
+ }
+ ICPPClassType clazz = getSpecializedBinding();
+ if (clazz != null) {
+ return clazz.isNoDiscard();
+ }
+ return false;
+ }
+
+ @Override
public int getVisibility(IBinding member) {
return ClassTypeHelper.getVisibility(this, member);
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassTemplate.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassTemplate.java
index f83a4e1092d..2a236677acb 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassTemplate.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassTemplate.java
@@ -44,6 +44,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPUsingDeclaration;
import org.eclipse.cdt.core.index.IIndexBinding;
import org.eclipse.cdt.core.index.IIndexFileSet;
import org.eclipse.cdt.core.parser.util.ArrayUtil;
+import org.eclipse.cdt.core.parser.util.AttributeUtil;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
/**
@@ -267,6 +268,15 @@ public class CPPClassTemplate extends CPPTemplateDefinition
}
@Override
+ public boolean isNoDiscard() {
+ ICPPASTCompositeTypeSpecifier typeSpecifier = getCompositeTypeSpecifier();
+ if (typeSpecifier != null) {
+ return AttributeUtil.hasNodiscardAttribute(typeSpecifier);
+ }
+ return false;
+ }
+
+ @Override
public int getVisibility(IBinding member) {
return ClassTypeHelper.getVisibility(this, member);
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassType.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassType.java
index 681b04811ef..b6dcea7c474 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassType.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassType.java
@@ -44,6 +44,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPUsingDeclaration;
import org.eclipse.cdt.core.index.IIndex;
import org.eclipse.cdt.core.index.IIndexBinding;
import org.eclipse.cdt.core.parser.util.ArrayUtil;
+import org.eclipse.cdt.core.parser.util.AttributeUtil;
import org.eclipse.cdt.internal.core.dom.Linkage;
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
@@ -142,6 +143,11 @@ public class CPPClassType extends PlatformObject implements ICPPInternalClassTyp
public int getVisibility(IBinding member) {
throw new IllegalArgumentException(member.getName() + " is not a member of " + getName()); //$NON-NLS-1$
}
+
+ @Override
+ public boolean isNoDiscard() {
+ return false;
+ }
}
private IASTName definition;
@@ -455,6 +461,15 @@ public class CPPClassType extends PlatformObject implements ICPPInternalClassTyp
return false;
}
+ @Override
+ public boolean isNoDiscard() {
+ ICPPASTCompositeTypeSpecifier typeSpecifier = getCompositeTypeSpecifier();
+ if (typeSpecifier != null) {
+ return AttributeUtil.hasNodiscardAttribute(typeSpecifier);
+ }
+ return false;
+ }
+
private IASTName stripQualifier(IASTName name) {
if (name instanceof ICPPASTQualifiedName) {
name = ((ICPPASTQualifiedName) name).getLastName();
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClosureType.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClosureType.java
index 204772e384a..e48cdcc4b2b 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClosureType.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClosureType.java
@@ -592,4 +592,9 @@ public class CPPClosureType extends PlatformObject implements ICPPClassType, ICP
return CPPClosureType.this.getConstructors();
}
}
+
+ @Override
+ public boolean isNoDiscard() {
+ return false;
+ }
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPDeferredClassInstance.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPDeferredClassInstance.java
index b95497e699e..d648d17d3e2 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPDeferredClassInstance.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPDeferredClassInstance.java
@@ -179,6 +179,11 @@ public class CPPDeferredClassInstance extends CPPUnknownBinding
}
@Override
+ public boolean isNoDiscard() {
+ return false;
+ }
+
+ @Override
public ICPPTemplateArgument[] getTemplateArguments() {
return fArguments;
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateTemplateParameter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateTemplateParameter.java
index c26466b0f54..f611b368510 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateTemplateParameter.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateTemplateParameter.java
@@ -260,6 +260,11 @@ public class CPPTemplateTemplateParameter extends CPPTemplateParameter
}
@Override
+ public boolean isNoDiscard() {
+ return false;
+ }
+
+ @Override
public int getVisibility(IBinding member) {
throw new IllegalArgumentException(member.getName() + " is not a member of " + getName()); //$NON-NLS-1$
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateTemplateParameterSpecialization.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateTemplateParameterSpecialization.java
index 2450a2a8957..b87ec89745d 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateTemplateParameterSpecialization.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateTemplateParameterSpecialization.java
@@ -128,6 +128,11 @@ public class CPPTemplateTemplateParameterSpecialization extends CPPTemplateParam
}
@Override
+ public boolean isNoDiscard() {
+ return false;
+ }
+
+ @Override
public int getVisibility(IBinding member) {
return getSpecializedBinding().getVisibility(member);
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUnknownMemberClass.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUnknownMemberClass.java
index c347d7cf817..db1b181bf19 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUnknownMemberClass.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUnknownMemberClass.java
@@ -140,6 +140,11 @@ public class CPPUnknownMemberClass extends CPPUnknownMember implements ICPPUnkno
}
@Override
+ public boolean isNoDiscard() {
+ return false;
+ }
+
+ @Override
public int getVisibility(IBinding member) {
throw new IllegalArgumentException(member.getName() + " is not a member of " + getName()); //$NON-NLS-1$
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPClassType.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPClassType.java
index 2151da243e6..7dccbf0d4fd 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPClassType.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPClassType.java
@@ -231,4 +231,9 @@ class CompositeCPPClassType extends CompositeCPPBinding implements ICPPClassType
public int getVisibility(IBinding member) {
return ((ICPPClassType) rbinding).getVisibility(member);
}
+
+ @Override
+ public boolean isNoDiscard() {
+ return ((ICPPClassType) rbinding).isNoDiscard();
+ }
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPTemplateTemplateParameter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPTemplateTemplateParameter.java
index 5c54eaf2687..0fbf4767490 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPTemplateTemplateParameter.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPTemplateTemplateParameter.java
@@ -191,6 +191,11 @@ public class CompositeCPPTemplateTemplateParameter extends CompositeCPPBinding
}
@Override
+ public boolean isNoDiscard() {
+ return false;
+ }
+
+ @Override
public int getVisibility(IBinding member) {
throw new IllegalArgumentException(member.getName() + " is not a member of " + getName()); //$NON-NLS-1$
}
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 ca095864e5a..6d9fc2f4028 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
@@ -305,10 +305,11 @@ public class PDOM extends PlatformObject implements IPDOM {
*
* CDT 9.12 development (version not supported on the 9.11.x branch)
* 216.0 - Added nodiscard function information, bug 534420
+ * 217.0 - Added nodiscard class/struct information, bug 534420
*/
- private static final int MIN_SUPPORTED_VERSION = version(216, 0);
- private static final int MAX_SUPPORTED_VERSION = version(216, Short.MAX_VALUE);
- private static final int DEFAULT_VERSION = version(216, 0);
+ private static final int MIN_SUPPORTED_VERSION = version(217, 0);
+ private static final int MAX_SUPPORTED_VERSION = version(217, Short.MAX_VALUE);
+ private static final int DEFAULT_VERSION = version(217, 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/dom/PDOMASTAdapter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMASTAdapter.java
index 18162597b25..94cc7f062ee 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMASTAdapter.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMASTAdapter.java
@@ -669,6 +669,11 @@ public class PDOMASTAdapter {
public int getVisibility(IBinding member) {
return ((ICPPClassType) fDelegate).getVisibility(member);
}
+
+ @Override
+ public boolean isNoDiscard() {
+ return ((ICPPClassType) fDelegate).isNoDiscard();
+ }
}
private static class AnonymousClassSpecialization extends AnonymousClassType implements ICPPClassSpecialization {
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassSpecialization.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassSpecialization.java
index a1161ad8cae..88e5ea11808 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassSpecialization.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassSpecialization.java
@@ -72,6 +72,7 @@ class PDOMCPPClassSpecialization extends PDOMCPPSpecialization
private static final byte FLAGS_FINAL = 0x01;
private static final byte FLAGS_HAS_OWN_SCOPE = 0x02;
+ private static final byte FLAGS_NODISCARD = 0x03;
private volatile ICPPClassScope fScope;
private ObjectMap specializationMap; // Obtained from the synchronized PDOM cache.
@@ -508,6 +509,16 @@ class PDOMCPPClassSpecialization extends PDOMCPPSpecialization
}
}
+ @Override
+ public boolean isNoDiscard() {
+ try {
+ return (getFlags() & FLAGS_NODISCARD) != 0;
+ } catch (CoreException e) {
+ CCorePlugin.log(e);
+ return false;
+ }
+ }
+
private boolean hasOwnScope() throws CoreException {
return (getFlags() & FLAGS_HAS_OWN_SCOPE) != 0;
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassType.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassType.java
index 1f2e920a8ff..2d5447c2c4e 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassType.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassType.java
@@ -60,8 +60,9 @@ class PDOMCPPClassType extends PDOMCPPBinding implements IPDOMCPPClassType, IPDO
private static final int ANONYMOUS = KEY + 1; // byte
private static final int FINAL = ANONYMOUS + 1; // byte
private static final int VISIBLE_TO_ADL_ONLY = FINAL + 1; // byte
+ private static final int NO_DISCARD = VISIBLE_TO_ADL_ONLY + 1; // byte
@SuppressWarnings("hiding")
- protected static final int RECORD_SIZE = VISIBLE_TO_ADL_ONLY + 1;
+ protected static final int RECORD_SIZE = NO_DISCARD + 1;
private PDOMCPPClassScope fScope; // No need for volatile, all fields of PDOMCPPClassScope are final.
@@ -73,6 +74,7 @@ class PDOMCPPClassType extends PDOMCPPBinding implements IPDOMCPPClassType, IPDO
setAnonymous(classType);
setFinal(classType);
setVisibleToAdlOnly(visibleToAdlOnly);
+ setNoDiscard(classType);
// Linked list is initialized by storage being zero'd by malloc.
}
@@ -97,6 +99,7 @@ class PDOMCPPClassType extends PDOMCPPBinding implements IPDOMCPPClassType, IPDO
setKind(ct);
setAnonymous(ct);
setFinal(ct);
+ setNoDiscard(ct);
super.update(linkage, newBinding);
}
}
@@ -113,6 +116,10 @@ class PDOMCPPClassType extends PDOMCPPBinding implements IPDOMCPPClassType, IPDO
getDB().putByte(record + FINAL, (byte) (ct.isFinal() ? 1 : 0));
}
+ private void setNoDiscard(ICPPClassType ct) throws CoreException {
+ getDB().putByte(record + NO_DISCARD, (byte) (ct.isNoDiscard() ? 1 : 0));
+ }
+
@Override
public void setVisibleToAdlOnly(boolean visibleToAdlOnly) throws CoreException {
getDB().putByte(record + VISIBLE_TO_ADL_ONLY, (byte) (visibleToAdlOnly ? 1 : 0));
@@ -280,6 +287,16 @@ class PDOMCPPClassType extends PDOMCPPBinding implements IPDOMCPPClassType, IPDO
}
@Override
+ public boolean isNoDiscard() {
+ try {
+ return getDB().getByte(record + NO_DISCARD) != 0;
+ } catch (CoreException e) {
+ CCorePlugin.log(e);
+ return false;
+ }
+ }
+
+ @Override
public boolean isVisibleToAdlOnly() {
try {
return getDB().getByte(record + VISIBLE_TO_ADL_ONLY) != 0;
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPTemplateTemplateParameter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPTemplateTemplateParameter.java
index b33a90157cc..5c8e1a76715 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPTemplateTemplateParameter.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPTemplateTemplateParameter.java
@@ -350,6 +350,11 @@ public class PDOMCPPTemplateTemplateParameter extends PDOMCPPBinding implements
}
@Override
+ public boolean isNoDiscard() {
+ return false;
+ }
+
+ @Override
public ICPPTemplateParameter adaptTemplateParameter(ICPPTemplateParameter param) {
int pos = param.getParameterPosition();
ICPPTemplateParameter[] pars = getTemplateParameters();

Back to the top