Skip to main content
aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorMarco Stornelli2020-03-13 12:03:57 +0000
committerMarco Stornelli2020-03-23 17:18:41 +0000
commit5f316f404506ab1d1d14f1d32843bbe2ed3da04f (patch)
treebed30536e4024e65afb7a6f89e37cdd2a5e39434 /core
parent67b441b1206ac1c387f0dac5d4fa43e30d0430cf (diff)
downloadorg.eclipse.cdt-5f316f404506ab1d1d14f1d32843bbe2ed3da04f.tar.gz
org.eclipse.cdt-5f316f404506ab1d1d14f1d32843bbe2ed3da04f.tar.xz
org.eclipse.cdt-5f316f404506ab1d1d14f1d32843bbe2ed3da04f.zip
Bug 534420 - Add initial support for [[nodiscard]] attribute
Diffstat (limited to 'core')
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/CPPFunctionTests.java14
-rw-r--r--core/org.eclipse.cdt.core.tests/resources/pdomtests/functionTests/modifiers.cpp6
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IFunction.java8
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/util/AttributeUtil.java10
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CFunction.java6
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassSpecialization.java5
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPDeferredFunction.java5
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunction.java24
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionSpecialization.java8
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionTemplate.java5
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUnknownMethod.java5
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/AutoTypeResolver.java5
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/c/CompositeCFunction.java5
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPFunction.java5
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOM.java9
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/c/PDOMCAnnotations.java12
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/c/PDOMCFunction.java5
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPAnnotations.java10
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPFunction.java5
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPFunctionSpecialization.java5
20 files changed, 154 insertions, 3 deletions
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/CPPFunctionTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/CPPFunctionTests.java
index 93890dc8307..cd056891704 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/CPPFunctionTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/CPPFunctionTests.java
@@ -152,6 +152,12 @@ public class CPPFunctionTests extends PDOMTestBase {
assertTrue(((ICPPFunction) bindings[0]).isNoReturn());
}
+ private void assertNoDiscardFunction(String functionName) throws CoreException {
+ IBinding[] bindings = findQualifiedName(pdom, functionName);
+ assertEquals(1, bindings.length);
+ assertTrue(((ICPPFunction) bindings[0]).isNoDiscard());
+ }
+
public void testNoReturnCPPFunction() throws Exception {
assertNoReturnFunction("noReturnCPPFunction");
assertNoReturnFunction("trailingNoReturnStdAttributeDecl");
@@ -160,6 +166,14 @@ public class CPPFunctionTests extends PDOMTestBase {
assertNoReturnFunction("leadingNoReturnStdAttributeDef");
}
+ public void testNoDiscardCPPFunction() throws Exception {
+ assertNoDiscardFunction("noDiscardCPPFunction");
+ assertNoDiscardFunction("trailingNoDiscardStdAttributeDecl");
+ assertNoDiscardFunction("leadingNoDiscardStdAttributeDecl");
+ assertNoDiscardFunction("trailingNoDiscardStdAttributeDef");
+ assertNoDiscardFunction("leadingNoDiscardStdAttributeDef");
+ }
+
public void testForwardDeclarationType() throws Exception {
assertType(pdom, "forwardDeclaration", ICPPFunction.class);
}
diff --git a/core/org.eclipse.cdt.core.tests/resources/pdomtests/functionTests/modifiers.cpp b/core/org.eclipse.cdt.core.tests/resources/pdomtests/functionTests/modifiers.cpp
index e64112ba4c5..e5e49c5ef14 100644
--- a/core/org.eclipse.cdt.core.tests/resources/pdomtests/functionTests/modifiers.cpp
+++ b/core/org.eclipse.cdt.core.tests/resources/pdomtests/functionTests/modifiers.cpp
@@ -10,6 +10,12 @@ void leadingNoReturnStdAttributeDecl() [[noreturn]];
[[noreturn]] void trailingNoReturnStdAttributeDef(){}
void leadingNoReturnStdAttributeDef() [[noreturn]]{}
+int noDiscardCPPFunction() __attribute__((warn_unused_result));
+[[nodiscard]] int trailingNoDiscardStdAttributeDecl();
+int leadingNoDiscardStdAttributeDecl() [[nodiscard]];
+[[nodiscard]] int trailingNoDiscardStdAttributeDef(){return 0;}
+int leadingNoDiscardStdAttributeDef() [[nodiscard]]{return 0;}
+
void voidCPPFunction();
int intCPPFunction();
double doubleCPPFunction();
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IFunction.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IFunction.java
index 4836983c15f..e3ff6117970 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IFunction.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IFunction.java
@@ -65,4 +65,12 @@ public interface IFunction extends IBinding {
* @since 5.4
*/
public boolean isNoReturn();
+
+ /**
+ * Returns {@code true} if return value of this function must not be discarded.
+ * Based on 'nodiscard' attribute in the function declaration or in C using
+ * the flag 'warn_unused_result'
+ * @since 6.12
+ */
+ public boolean isNoDiscard();
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/util/AttributeUtil.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/util/AttributeUtil.java
index 78c66dda80f..386fb5de740 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/util/AttributeUtil.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/util/AttributeUtil.java
@@ -26,6 +26,8 @@ import org.eclipse.cdt.core.parser.StandardAttributes;
*/
public class AttributeUtil {
private static final String[] ATTRIBUTE_NORETURN = new String[] { "__noreturn__", StandardAttributes.NORETURN }; //$NON-NLS-1$
+ private static final String[] ATTRIBUTE_NODISCARD = new String[] { "warn_unused_result", //$NON-NLS-1$
+ StandardAttributes.NODISCARD };
// Not instantiatable.
private AttributeUtil() {
@@ -55,6 +57,14 @@ public class AttributeUtil {
}
/**
+ * Returns {@code true} if the node has a "nodiscard" attribute.
+ * @since 6.12
+ */
+ public static boolean hasNodiscardAttribute(IASTAttributeOwner node) {
+ return hasAttribute(node, ATTRIBUTE_NODISCARD);
+ }
+
+ /**
* Returns character representation of the attribute argument, or {@code null} if the attribute
* has zero or more than one argument.
*/
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CFunction.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CFunction.java
index 6fb3529f223..6a4e6f842e8 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CFunction.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CFunction.java
@@ -496,6 +496,12 @@ public class CFunction extends PlatformObject implements IFunction, ICInternalFu
return dtor != null && AttributeUtil.hasNoreturnAttribute(dtor);
}
+ @Override
+ public boolean isNoDiscard() {
+ IASTFunctionDeclarator dtor = getPreferredDtor();
+ return dtor != null && AttributeUtil.hasNodiscardAttribute(dtor);
+ }
+
protected IASTFunctionDeclarator getPreferredDtor() {
IASTFunctionDeclarator dtor = getDefinition();
if (dtor != null)
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 174e0e260f8..11b3070e16b 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
@@ -161,6 +161,11 @@ public class CPPClassSpecialization extends CPPSpecialization
public boolean isConstexpr() {
return false;
}
+
+ @Override
+ public boolean isNoDiscard() {
+ return false;
+ }
}
public final static class RecursionResolvingConstructor extends RecursionResolvingMethod
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPDeferredFunction.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPDeferredFunction.java
index cf64816dfbc..9d6d8b2afd2 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPDeferredFunction.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPDeferredFunction.java
@@ -160,6 +160,11 @@ public class CPPDeferredFunction extends CPPUnknownBinding
}
@Override
+ public boolean isNoDiscard() {
+ return false;
+ }
+
+ @Override
public int getRequiredArgumentCount() {
return 0;
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunction.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunction.java
index 391a4db7bb3..89972bb48ce 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunction.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunction.java
@@ -104,6 +104,11 @@ public class CPPFunction extends PlatformObject implements ICPPFunction, ICPPInt
public int getRequiredArgumentCount() {
return 0;
}
+
+ @Override
+ public boolean isNoDiscard() {
+ return false;
+ }
}
public static final ICPPFunction UNINITIALIZED_FUNCTION = new CPPFunction(null) {
@@ -739,6 +744,11 @@ public class CPPFunction extends PlatformObject implements ICPPFunction, ICPPInt
return isNoReturn(getPreferredDtor());
}
+ @Override
+ public boolean isNoDiscard() {
+ return isNoDiscard(getPreferredDtor());
+ }
+
public static boolean isNoReturn(ICPPASTFunctionDeclarator dtor) {
if (dtor == null) {
return false;
@@ -753,6 +763,20 @@ public class CPPFunction extends PlatformObject implements ICPPFunction, ICPPInt
return false;
}
+ public static boolean isNoDiscard(ICPPASTFunctionDeclarator dtor) {
+ if (dtor == null) {
+ return false;
+ }
+ if (AttributeUtil.hasNodiscardAttribute(dtor)) {
+ return true;
+ }
+ IASTNode parent = dtor.getParent();
+ if (parent instanceof IASTAttributeOwner) {
+ return AttributeUtil.hasNodiscardAttribute((IASTAttributeOwner) parent);
+ }
+ return false;
+ }
+
public static ICPPExecution getFunctionBodyExecution(ICPPFunction function) {
if (function instanceof ICPPComputableFunction) {
return ((ICPPComputableFunction) function).getFunctionBodyExecution();
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionSpecialization.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionSpecialization.java
index bba88ff46df..65aaaf44918 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionSpecialization.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionSpecialization.java
@@ -341,4 +341,12 @@ public class CPPFunctionSpecialization extends CPPSpecialization
}
return CPPTemplates.instantiateFunctionBody(this);
}
+
+ @Override
+ public boolean isNoDiscard() {
+ ICPPFunction f = (ICPPFunction) getSpecializedBinding();
+ if (f != null)
+ return f.isNoDiscard();
+ return false;
+ }
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionTemplate.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionTemplate.java
index a5e631763ee..82dc9160332 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionTemplate.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionTemplate.java
@@ -392,6 +392,11 @@ public class CPPFunctionTemplate extends CPPTemplateDefinition implements ICPPFu
return CPPFunction.isNoReturn(getFirstFunctionDtor());
}
+ @Override
+ public boolean isNoDiscard() {
+ return CPPFunction.isNoDiscard(getFirstFunctionDtor());
+ }
+
private IASTDeclarator getDeclaratorByName(IASTNode node) {
// Skip qualified names and nested declarators.
while (node != null) {
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUnknownMethod.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUnknownMethod.java
index abe90b7f058..c4a169a53fd 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUnknownMethod.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUnknownMethod.java
@@ -174,4 +174,9 @@ public class CPPUnknownMethod extends CPPUnknownMember implements ICPPMethod {
public boolean isConstexpr() {
return false;
}
+
+ @Override
+ public boolean isNoDiscard() {
+ return false;
+ }
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/AutoTypeResolver.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/AutoTypeResolver.java
index 8a4bb012a8c..4f2c88e64fa 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/AutoTypeResolver.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/AutoTypeResolver.java
@@ -183,4 +183,9 @@ class AutoTypeResolver implements ICPPFunctionTemplate {
public boolean isNoReturn() {
throw new UnsupportedOperationException(UNEXPECTED_CALL);
}
+
+ @Override
+ public boolean isNoDiscard() {
+ throw new UnsupportedOperationException(UNEXPECTED_CALL);
+ }
} \ No newline at end of file
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/c/CompositeCFunction.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/c/CompositeCFunction.java
index bc2ab8d1380..74669ea2251 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/c/CompositeCFunction.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/c/CompositeCFunction.java
@@ -83,4 +83,9 @@ class CompositeCFunction extends CompositeCBinding implements IFunction {
public boolean isNoReturn() {
return ((IFunction) rbinding).isNoReturn();
}
+
+ @Override
+ public boolean isNoDiscard() {
+ return ((IFunction) rbinding).isNoDiscard();
+ }
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPFunction.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPFunction.java
index cf41dbde615..3b8467a5fcf 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPFunction.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPFunction.java
@@ -152,4 +152,9 @@ class CompositeCPPFunction extends CompositeCPPBinding implements ICPPFunction,
public ICPPExecution getFunctionBodyExecution() {
return CPPFunction.getFunctionBodyExecution((ICPPFunction) rbinding);
}
+
+ @Override
+ public boolean isNoDiscard() {
+ return ((ICPPFunction) rbinding).isNoDiscard();
+ }
}
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 086d14bb9d7..ca095864e5a 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
@@ -302,10 +302,13 @@ public class PDOM extends PlatformObject implements IPDOM {
*
* CDT 9.9 development (version not supported on the 9.8.x branch)
* 215.0 - Corruption due to wrong record size in field/variable template partial specialization, bug 549028.
+ *
+ * CDT 9.12 development (version not supported on the 9.11.x branch)
+ * 216.0 - Added nodiscard function information, bug 534420
*/
- private static final int MIN_SUPPORTED_VERSION = version(215, 0);
- private static final int MAX_SUPPORTED_VERSION = version(215, Short.MAX_VALUE);
- private static final int DEFAULT_VERSION = version(215, 0);
+ 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 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/c/PDOMCAnnotations.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/c/PDOMCAnnotations.java
index e842e2aeb81..64da027c55a 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/c/PDOMCAnnotations.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/c/PDOMCAnnotations.java
@@ -32,6 +32,9 @@ class PDOMCAnnotations {
private static final int NO_RETURN_OFFSET = 4;
private static final int REGISTER_OFFSET = 5;
private static final int AUTO_OFFSET = 6;
+ private static final int NO_DISCARD_OFFSET = 7;
+ //NOTE: we are writing these annotations on a "byte" so if we need
+ //to add another value we need to use at least a short.
/**
* Encodes annotations applicable to functions.
@@ -55,6 +58,8 @@ class PDOMCAnnotations {
annotation |= 1 << REGISTER_OFFSET;
if (function.isAuto())
annotation |= 1 << AUTO_OFFSET;
+ if (function.isNoDiscard())
+ annotation |= 1 << NO_DISCARD_OFFSET;
return annotation;
}
@@ -115,6 +120,13 @@ class PDOMCAnnotations {
}
/**
+ * Checks if the "no discard" annotation is set.
+ */
+ public static boolean isNoDiscardFunction(short annotation) {
+ return (annotation & (1 << NO_DISCARD_OFFSET)) != 0;
+ }
+
+ /**
* Checks if the "register" annotation is set.
*/
public static boolean isRegister(byte annotation) {
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/c/PDOMCFunction.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/c/PDOMCFunction.java
index 5230308ea5f..07ddfcffbda 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/c/PDOMCFunction.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/c/PDOMCFunction.java
@@ -208,4 +208,9 @@ class PDOMCFunction extends PDOMBinding implements IFunction {
public IScope getFunctionScope() {
return null;
}
+
+ @Override
+ public boolean isNoDiscard() {
+ return PDOMCAnnotations.isNoDiscardFunction(getAnnotations());
+ }
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPAnnotations.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPAnnotations.java
index c7c020c36b5..709f9bc84be 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPAnnotations.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPAnnotations.java
@@ -45,6 +45,7 @@ class PDOMCPPAnnotations {
private static final int PARAMETER_PACK_OFFSET = 7;
private static final int DELETED_OFFSET = 8;
private static final int NO_RETURN_OFFSET = 9;
+ private static final int NO_DISCARD_OFFSET = 10;
// Method annotations that don't fit on the first 16 bits of annotations.
private static final int VIRTUAL_OFFSET = 0;
@@ -82,6 +83,8 @@ class PDOMCPPAnnotations {
annotation |= 1 << PARAMETER_PACK_OFFSET;
if (function.isDeleted())
annotation |= 1 << DELETED_OFFSET;
+ if (function.isNoDiscard())
+ annotation |= 1 << NO_DISCARD_OFFSET;
return annotation;
}
@@ -227,6 +230,13 @@ class PDOMCPPAnnotations {
}
/**
+ * Checks if the "no discard" annotation is set.
+ */
+ public static boolean isNoDiscardFunction(short annotation) {
+ return (annotation & (1 << NO_DISCARD_OFFSET)) != 0;
+ }
+
+ /**
* Checks if the "virtual" annotation is set.
*/
public static boolean isVirtualMethod(byte annotation) {
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPFunction.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPFunction.java
index 6797e525149..01e8334a218 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPFunction.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPFunction.java
@@ -449,4 +449,9 @@ class PDOMCPPFunction extends PDOMCPPBinding implements ICPPFunction, IPDOMOverl
return null;
}
}
+
+ @Override
+ public boolean isNoDiscard() {
+ return PDOMCPPAnnotations.isNoDiscardFunction(getAnnotations());
+ }
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPFunctionSpecialization.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPFunctionSpecialization.java
index 9b047058a57..6f62bec830b 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPFunctionSpecialization.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPFunctionSpecialization.java
@@ -342,4 +342,9 @@ class PDOMCPPFunctionSpecialization extends PDOMCPPSpecialization
return null;
}
}
+
+ @Override
+ public boolean isNoDiscard() {
+ return PDOMCPPAnnotations.isNoDiscardFunction(getAnnotations());
+ }
}

Back to the top