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 d9b31ef9f..3708d1380 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 @@ -38,11 +38,15 @@ import pt.up.fe.specs.clava.ast.decl.data.nestedname.TypeSpecSpecifier; import pt.up.fe.specs.clava.ast.decl.data.nestedname.TypeSpecWithTemplateSpecifier; import pt.up.fe.specs.clava.ast.decl.data.templates.TemplateArgument; +import pt.up.fe.specs.clava.ast.decl.data.templates.TemplateArgumentDeclaration; import pt.up.fe.specs.clava.ast.decl.data.templates.TemplateArgumentExpr; import pt.up.fe.specs.clava.ast.decl.data.templates.TemplateArgumentIntegral; import pt.up.fe.specs.clava.ast.decl.data.templates.TemplateArgumentKind; +import pt.up.fe.specs.clava.ast.decl.data.templates.TemplateArgumentNullPtr; import pt.up.fe.specs.clava.ast.decl.data.templates.TemplateArgumentPack; +import pt.up.fe.specs.clava.ast.decl.data.templates.TemplateArgumentStructuralValue; import pt.up.fe.specs.clava.ast.decl.data.templates.TemplateArgumentTemplate; +import pt.up.fe.specs.clava.ast.decl.data.templates.TemplateArgumentTemplateExpansion; import pt.up.fe.specs.clava.ast.decl.data.templates.TemplateArgumentType; import pt.up.fe.specs.clava.ast.decl.data.templates.template.QualifiedTemplate; import pt.up.fe.specs.clava.ast.decl.data.templates.template.SubstTemplateTemplateParm; @@ -257,6 +261,14 @@ public static TemplateArgument templateArgument(LineStream lines, ClangAstData p TemplateArgumentKind kind = LineStreamParsers.enumFromName(TemplateArgumentKind.class, lines); switch (kind) { + case Declaration: + TemplateArgumentDeclaration declaration = new TemplateArgumentDeclaration(); + parserData.getClavaNodes().queueSetNode(declaration, TemplateArgumentDeclaration.DECL, lines.nextLine()); + return declaration; + case NullPtr: + TemplateArgumentNullPtr nullPtr = new TemplateArgumentNullPtr(); + parserData.getClavaNodes().queueSetNode(nullPtr, TemplateArgumentNullPtr.TYPE, lines.nextLine()); + return nullPtr; case Type: TemplateArgumentType type = new TemplateArgumentType(); parserData.getClavaNodes().queueSetNode(type, TemplateArgumentType.TYPE, lines.nextLine()); @@ -282,6 +294,19 @@ public static TemplateArgument templateArgument(LineStream lines, ClangAstData p return integral; case Template: return templateArgumentTemplate(lines, parserData); + case TemplateExpansion: + TemplateArgumentTemplateExpansion expansion = new TemplateArgumentTemplateExpansion(); + String numExpansions = lines.nextLine(); + expansion.set(TemplateArgumentTemplateExpansion.NUM_EXPANSIONS, + numExpansions.isEmpty() ? Optional.empty() : Optional.of(Integer.parseInt(numExpansions))); + expansion.set(TemplateArgumentTemplateExpansion.TEMPLATE, + templateArgumentTemplate(lines, parserData)); + return expansion; + case StructuralValue: + TemplateArgumentStructuralValue structuralValue = new TemplateArgumentStructuralValue(); + parserData.getClavaNodes().queueSetNode(structuralValue, TemplateArgumentStructuralValue.TYPE, + lines.nextLine()); + return structuralValue; /* // TemplateArgumentTemplate template = new TemplateArgumentTemplate(); TemplateNameKind nameKind = LineStreamParsers.enumFromName(TemplateNameKind.class, lines); diff --git a/ClavaAst/src/pt/up/fe/specs/clava/ast/decl/data/templates/TemplateArgumentDeclaration.java b/ClavaAst/src/pt/up/fe/specs/clava/ast/decl/data/templates/TemplateArgumentDeclaration.java new file mode 100644 index 000000000..43ada802a --- /dev/null +++ b/ClavaAst/src/pt/up/fe/specs/clava/ast/decl/data/templates/TemplateArgumentDeclaration.java @@ -0,0 +1,32 @@ +/** + * 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.decl.data.templates; + +import org.suikasoft.jOptions.Datakey.DataKey; +import org.suikasoft.jOptions.Datakey.KeyFactory; + +import pt.up.fe.specs.clava.ast.decl.Decl; + +public class TemplateArgumentDeclaration extends TemplateArgument { + + /// DATAKEYS BEGIN + + public final static DataKey DECL = KeyFactory.object("decl", Decl.class); + + /// DATAKEYS END + + public TemplateArgumentDeclaration() { + super(TemplateArgumentKind.Declaration); + } +} diff --git a/ClavaAst/src/pt/up/fe/specs/clava/ast/decl/data/templates/TemplateArgumentKind.java b/ClavaAst/src/pt/up/fe/specs/clava/ast/decl/data/templates/TemplateArgumentKind.java index c488dea9c..d3c09b67a 100644 --- a/ClavaAst/src/pt/up/fe/specs/clava/ast/decl/data/templates/TemplateArgumentKind.java +++ b/ClavaAst/src/pt/up/fe/specs/clava/ast/decl/data/templates/TemplateArgumentKind.java @@ -39,5 +39,9 @@ public enum TemplateArgumentKind { /** * A parameter pack. */ - Pack + Pack, + /** + * A structural value for a non-type template parameter. + */ + StructuralValue } diff --git a/ClavaAst/src/pt/up/fe/specs/clava/ast/decl/data/templates/TemplateArgumentNullPtr.java b/ClavaAst/src/pt/up/fe/specs/clava/ast/decl/data/templates/TemplateArgumentNullPtr.java new file mode 100644 index 000000000..f067aa01b --- /dev/null +++ b/ClavaAst/src/pt/up/fe/specs/clava/ast/decl/data/templates/TemplateArgumentNullPtr.java @@ -0,0 +1,38 @@ +/** + * 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.decl.data.templates; + +import org.suikasoft.jOptions.Datakey.DataKey; +import org.suikasoft.jOptions.Datakey.KeyFactory; + +import pt.up.fe.specs.clava.ClavaNode; +import pt.up.fe.specs.clava.ast.type.Type; + +public class TemplateArgumentNullPtr extends TemplateArgument { + + /// DATAKEYS BEGIN + + public final static DataKey TYPE = KeyFactory.object("type", Type.class); + + /// DATAKEYS END + + public TemplateArgumentNullPtr() { + super(TemplateArgumentKind.NullPtr); + } + + @Override + public String getCode(ClavaNode node) { + return "nullptr"; + } +} diff --git a/ClavaAst/src/pt/up/fe/specs/clava/ast/decl/data/templates/TemplateArgumentStructuralValue.java b/ClavaAst/src/pt/up/fe/specs/clava/ast/decl/data/templates/TemplateArgumentStructuralValue.java new file mode 100644 index 000000000..a582cf832 --- /dev/null +++ b/ClavaAst/src/pt/up/fe/specs/clava/ast/decl/data/templates/TemplateArgumentStructuralValue.java @@ -0,0 +1,32 @@ +/** + * 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.decl.data.templates; + +import org.suikasoft.jOptions.Datakey.DataKey; +import org.suikasoft.jOptions.Datakey.KeyFactory; + +import pt.up.fe.specs.clava.ast.type.Type; + +public class TemplateArgumentStructuralValue extends TemplateArgument { + + /// DATAKEYS BEGIN + + public final static DataKey TYPE = KeyFactory.object("type", Type.class); + + /// DATAKEYS END + + public TemplateArgumentStructuralValue() { + super(TemplateArgumentKind.StructuralValue); + } +} diff --git a/ClavaAst/src/pt/up/fe/specs/clava/ast/decl/data/templates/TemplateArgumentTemplateExpansion.java b/ClavaAst/src/pt/up/fe/specs/clava/ast/decl/data/templates/TemplateArgumentTemplateExpansion.java new file mode 100644 index 000000000..d4593d618 --- /dev/null +++ b/ClavaAst/src/pt/up/fe/specs/clava/ast/decl/data/templates/TemplateArgumentTemplateExpansion.java @@ -0,0 +1,42 @@ +/** + * 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.decl.data.templates; + +import java.util.Optional; + +import org.suikasoft.jOptions.Datakey.DataKey; +import org.suikasoft.jOptions.Datakey.KeyFactory; + +import pt.up.fe.specs.clava.ClavaNode; + +public class TemplateArgumentTemplateExpansion extends TemplateArgument { + + /// DATAKEYS BEGIN + + public final static DataKey> NUM_EXPANSIONS = KeyFactory.optional("numExpansions"); + + public final static DataKey TEMPLATE = KeyFactory.object("template", + TemplateArgumentTemplate.class); + + /// DATAKEYS END + + public TemplateArgumentTemplateExpansion() { + super(TemplateArgumentKind.TemplateExpansion); + } + + @Override + public String getCode(ClavaNode node) { + return get(TEMPLATE).getCode(node) + "..."; + } +}