1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-22 14:12:10 +02:00

Bug 534420 - Fix enums nodiscard flag size in the index

Change-Id: Ifaf5de849a8b95217ce112306f471dbcdc781f3d
This commit is contained in:
Marco Stornelli 2020-04-08 14:23:20 +02:00
parent 87a3be448e
commit 2a0bc541f0
2 changed files with 21 additions and 9 deletions

View file

@ -307,10 +307,11 @@ public class PDOM extends PlatformObject implements IPDOM {
* 216.0 - Added nodiscard function information, bug 534420 * 216.0 - Added nodiscard function information, bug 534420
* 217.0 - Added nodiscard class/struct information, bug 534420 * 217.0 - Added nodiscard class/struct information, bug 534420
* 218.0 - Added nodiscard enums information, bug 534420 * 218.0 - Added nodiscard enums information, bug 534420
* 219.0 - Fix enums nodiscard information in the index from 8 byte to 1 byte, bug 534420
*/ */
private static final int MIN_SUPPORTED_VERSION = version(218, 0); private static final int MIN_SUPPORTED_VERSION = version(219, 0);
private static final int MAX_SUPPORTED_VERSION = version(218, Short.MAX_VALUE); private static final int MAX_SUPPORTED_VERSION = version(219, Short.MAX_VALUE);
private static final int DEFAULT_VERSION = version(218, 0); private static final int DEFAULT_VERSION = version(219, 0);
private static int version(int major, int minor) { private static int version(int major, int minor) {
return (major << 16) + minor; return (major << 16) + minor;

View file

@ -49,8 +49,10 @@ class PDOMCPPEnumeration extends PDOMCPPBinding implements IPDOMCPPEnumType, IPD
private static final int OFFSET_MIN_VALUE = OFFSET_ENUMERATOR_LIST + Database.PTR_SIZE; private static final int OFFSET_MIN_VALUE = OFFSET_ENUMERATOR_LIST + Database.PTR_SIZE;
private static final int OFFSET_MAX_VALUE = OFFSET_MIN_VALUE + 8; private static final int OFFSET_MAX_VALUE = OFFSET_MIN_VALUE + 8;
private static final int OFFSET_FIXED_TYPE = OFFSET_MAX_VALUE + 8; private static final int OFFSET_FIXED_TYPE = OFFSET_MAX_VALUE + 8;
private static final int OFFSET_NO_DISCARD = OFFSET_FIXED_TYPE + 8; private static final int OFFSET_FLAGS = OFFSET_FIXED_TYPE + Database.TYPE_SIZE;
private static final int OFFSET_FLAGS = OFFSET_NO_DISCARD + Database.TYPE_SIZE;
private static final byte FLAG_SCOPED = 0x1;
private static final byte FLAG_NODISCARD = 0x2;
@SuppressWarnings("hiding") @SuppressWarnings("hiding")
protected static final int RECORD_SIZE = OFFSET_FLAGS + 1; protected static final int RECORD_SIZE = OFFSET_FLAGS + 1;
@ -76,8 +78,15 @@ class PDOMCPPEnumeration extends PDOMCPPBinding implements IPDOMCPPEnumType, IPD
private void storeProperties(ICPPEnumeration enumeration) throws CoreException { private void storeProperties(ICPPEnumeration enumeration) throws CoreException {
final Database db = getDB(); final Database db = getDB();
db.putByte(record + OFFSET_FLAGS, enumeration.isScoped() ? (byte) 1 : (byte) 0); byte flags = 0;
db.putByte(record + OFFSET_NO_DISCARD, enumeration.isNoDiscard() ? (byte) 1 : (byte) 0); if (enumeration.isScoped()) {
flags |= FLAG_SCOPED;
}
if (enumeration.isNoDiscard()) {
flags |= FLAG_NODISCARD;
}
db.putByte(record + OFFSET_FLAGS, flags);
getLinkage().storeType(record + OFFSET_FIXED_TYPE, enumeration.getFixedType()); getLinkage().storeType(record + OFFSET_FIXED_TYPE, enumeration.getFixedType());
@ -190,7 +199,8 @@ class PDOMCPPEnumeration extends PDOMCPPBinding implements IPDOMCPPEnumType, IPD
@Override @Override
public boolean isScoped() { public boolean isScoped() {
try { try {
return getDB().getByte(record + OFFSET_FLAGS) != 0; byte flags = getDB().getByte(record + OFFSET_FLAGS);
return (flags & FLAG_SCOPED) != 0;
} catch (CoreException e) { } catch (CoreException e) {
return false; return false;
} }
@ -199,7 +209,8 @@ class PDOMCPPEnumeration extends PDOMCPPBinding implements IPDOMCPPEnumType, IPD
@Override @Override
public boolean isNoDiscard() { public boolean isNoDiscard() {
try { try {
return getDB().getByte(record + OFFSET_NO_DISCARD) != 0; byte flags = getDB().getByte(record + OFFSET_FLAGS);
return (flags & FLAG_NODISCARD) != 0;
} catch (CoreException e) { } catch (CoreException e) {
return false; return false;
} }