From 5f316f404506ab1d1d14f1d32843bbe2ed3da04f Mon Sep 17 00:00:00 2001 From: Marco Stornelli Date: Fri, 13 Mar 2020 13:03:57 +0100 Subject: [PATCH] Bug 534420 - Add initial support for [[nodiscard]] attribute Change-Id: I3bb7e1b4068c5e95a8247be152b9e428f9207bdc --- .../internal/pdom/tests/CPPFunctionTests.java | 14 +++++++++++ .../pdomtests/functionTests/modifiers.cpp | 6 +++++ .../eclipse/cdt/core/dom/ast/IFunction.java | 8 +++++++ .../cdt/core/parser/util/AttributeUtil.java | 10 ++++++++ .../internal/core/dom/parser/c/CFunction.java | 6 +++++ .../parser/cpp/CPPClassSpecialization.java | 5 ++++ .../dom/parser/cpp/CPPDeferredFunction.java | 5 ++++ .../core/dom/parser/cpp/CPPFunction.java | 24 +++++++++++++++++++ .../parser/cpp/CPPFunctionSpecialization.java | 8 +++++++ .../dom/parser/cpp/CPPFunctionTemplate.java | 5 ++++ .../core/dom/parser/cpp/CPPUnknownMethod.java | 5 ++++ .../cpp/semantics/AutoTypeResolver.java | 5 ++++ .../index/composite/c/CompositeCFunction.java | 5 ++++ .../composite/cpp/CompositeCPPFunction.java | 5 ++++ .../eclipse/cdt/internal/core/pdom/PDOM.java | 9 ++++--- .../core/pdom/dom/c/PDOMCAnnotations.java | 12 ++++++++++ .../core/pdom/dom/c/PDOMCFunction.java | 5 ++++ .../core/pdom/dom/cpp/PDOMCPPAnnotations.java | 10 ++++++++ .../core/pdom/dom/cpp/PDOMCPPFunction.java | 5 ++++ .../cpp/PDOMCPPFunctionSpecialization.java | 5 ++++ .../META-INF/MANIFEST.MF | 2 +- .../lrparser/c99/bindings/C99Function.java | 10 ++++++++ 22 files changed, 165 insertions(+), 4 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() { @@ -54,6 +56,14 @@ public class AttributeUtil { return hasAttribute(node, ATTRIBUTE_NORETURN); } + /** + * 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 @@ -159,6 +159,11 @@ public class CPPDeferredFunction extends CPPUnknownBinding return false; } + @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; } @@ -114,6 +119,13 @@ class PDOMCAnnotations { return (annotation & (1 << NO_RETURN_OFFSET)) != 0; } + /** + * 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. */ 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; } @@ -226,6 +229,13 @@ class PDOMCPPAnnotations { return (annotation & (1 << NO_RETURN_OFFSET)) != 0; } + /** + * 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. */ 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()); + } } diff --git a/lrparser/org.eclipse.cdt.core.lrparser/META-INF/MANIFEST.MF b/lrparser/org.eclipse.cdt.core.lrparser/META-INF/MANIFEST.MF index 21aae609c4d..8d7fd382399 100644 --- a/lrparser/org.eclipse.cdt.core.lrparser/META-INF/MANIFEST.MF +++ b/lrparser/org.eclipse.cdt.core.lrparser/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %Bundle-Name.1 Bundle-SymbolicName: org.eclipse.cdt.core.lrparser;singleton:=true -Bundle-Version: 5.2.300.qualifier +Bundle-Version: 5.2.400.qualifier Bundle-ClassPath: . Require-Bundle: org.eclipse.cdt.core, net.sourceforge.lpg.lpgjavaruntime;bundle-version="1.1.0";visibility:=reexport, diff --git a/lrparser/org.eclipse.cdt.core.lrparser/old/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/C99Function.java b/lrparser/org.eclipse.cdt.core.lrparser/old/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/C99Function.java index b6c73081316..c8e83c5a841 100644 --- a/lrparser/org.eclipse.cdt.core.lrparser/old/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/C99Function.java +++ b/lrparser/org.eclipse.cdt.core.lrparser/old/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/C99Function.java @@ -39,6 +39,7 @@ public class C99Function extends PlatformObject implements IC99Binding, IFunctio private boolean isStatic; private boolean isVarArgs; private boolean isNoReturn; + private boolean isNoDiscard; // the scope that the function is in (must be the global scope, no?) private IScope scope; @@ -181,4 +182,13 @@ public class C99Function extends PlatformObject implements IC99Binding, IFunctio public IBinding getOwner() { return null; } + + @Override + public boolean isNoDiscard() { + return isNoDiscard; + } + + public void setNoDiscard(boolean isNoDiscard) { + this.isNoDiscard = isNoDiscard; + } }