diff --git a/ClangAstParser/src/pt/up/fe/specs/clang/parsers/data/ClavaDataParsers.java b/ClangAstParser/src/pt/up/fe/specs/clang/parsers/data/ClavaDataParsers.java index 531c6feea..2e3c7c9ff 100644 --- a/ClangAstParser/src/pt/up/fe/specs/clang/parsers/data/ClavaDataParsers.java +++ b/ClangAstParser/src/pt/up/fe/specs/clang/parsers/data/ClavaDataParsers.java @@ -60,6 +60,7 @@ import pt.up.fe.specs.clava.ast.expr.data.designator.Designator; import pt.up.fe.specs.clava.ast.expr.data.designator.FieldDesignator; import pt.up.fe.specs.clava.ast.expr.data.offsetof.OffsetOfArray; +import pt.up.fe.specs.clava.ast.expr.data.offsetof.OffsetOfBase; import pt.up.fe.specs.clava.ast.expr.data.offsetof.OffsetOfComponent; import pt.up.fe.specs.clava.ast.expr.data.offsetof.OffsetOfComponentKind; import pt.up.fe.specs.clava.ast.expr.data.offsetof.OffsetOfField; @@ -459,6 +460,9 @@ public static OffsetOfComponent offsetOfComponent(LineStream lines, ClangAstData case IDENTIFIER: component.set(OffsetOfIdentifier.FIELD_NAME, lines.nextLine()); break; + case BASE: + parserData.getClavaNodes().queueSetNode(component, OffsetOfBase.TYPE, lines.nextLine()); + break; default: throw new NotImplementedException(kind); } diff --git a/ClavaAst/src/pt/up/fe/specs/clava/ast/expr/OffsetOfExpr.java b/ClavaAst/src/pt/up/fe/specs/clava/ast/expr/OffsetOfExpr.java index bf5ab5083..2ef7f313f 100644 --- a/ClavaAst/src/pt/up/fe/specs/clava/ast/expr/OffsetOfExpr.java +++ b/ClavaAst/src/pt/up/fe/specs/clava/ast/expr/OffsetOfExpr.java @@ -50,18 +50,20 @@ private String getComponentsCode() { StringBuilder code = new StringBuilder(); - boolean isFirst = true; + boolean hasCode = false; for (OffsetOfComponent component : get(COMPONENTS)) { + String componentCode = component.getCode(); - if (component.isField() && !isFirst) { - code.append("."); + if (componentCode.isEmpty()) { + continue; } - code.append(component.getCode()); - - if (isFirst) { - isFirst = false; + if (component.isField() && hasCode) { + code.append("."); } + + code.append(componentCode); + hasCode = true; } return code.toString(); } diff --git a/ClavaAst/src/pt/up/fe/specs/clava/ast/expr/data/offsetof/OffsetOfBase.java b/ClavaAst/src/pt/up/fe/specs/clava/ast/expr/data/offsetof/OffsetOfBase.java new file mode 100644 index 000000000..b52ecf056 --- /dev/null +++ b/ClavaAst/src/pt/up/fe/specs/clava/ast/expr/data/offsetof/OffsetOfBase.java @@ -0,0 +1,39 @@ +/** + * Copyright 2026 SPeCS. + *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + *
+ * http://www.apache.org/licenses/LICENSE-2.0 + *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
+ * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations under the License.
+ */
+
+package pt.up.fe.specs.clava.ast.expr.data.offsetof;
+
+import org.suikasoft.jOptions.Datakey.DataKey;
+import org.suikasoft.jOptions.Datakey.KeyFactory;
+
+import pt.up.fe.specs.clava.ast.type.Type;
+
+public class OffsetOfBase extends OffsetOfComponent {
+
+ /// DATAKEYS BEGIN
+
+ public final static DataKey