[lld] [LLD] Add CLASS syntax to SECTIONS (PR #95323)
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 22 14:55:03 PDT 2024
================
@@ -585,6 +587,34 @@ SmallVector<SectionCommand *, 0> ScriptParser::readOverlay() {
return v;
}
+SectionClassDesc *ScriptParser::readSectionClassDescription() {
+ StringRef name = readSectionClassName();
+ SectionClassDesc *desc = make<SectionClassDesc>(name);
+ if (!script->sectionClasses.insert({name, desc}).second)
+ setError("section class '" + name + "' already defined");
+ expect("{");
+ while (!errorCount() && !consume("}")) {
+ StringRef tok = next();
+ if (tok == "(" || tok == ")") {
+ setError("expected filename pattern");
+ } else if (peek() == "(") {
+ InputSectionDescription *isd = readInputSectionDescription(tok);
+ if (!isd->classRef.empty())
+ setError("section class '" + name + "' references class '" +
+ isd->classRef + "'");
+ desc->sc.commands.push_back(isd);
+ }
+ }
+ return desc;
+}
+
+StringRef ScriptParser::readSectionClassName() {
+ expect("(");
+ StringRef name = next();
----------------
MaskRay wrote:
We could use `unquote` to allow quoted name or just reject quoted names.
https://github.com/llvm/llvm-project/pull/95323
More information about the llvm-commits
mailing list