================ @@ -7806,6 +7815,267 @@ bool AArch64AsmParser::parseDirectiveSEHSaveAnyReg(SMLoc L, bool Paired, return false; } +bool AArch64AsmParser::parseDirectiveAeabiSubSectionHeader(SMLoc L) { + // Expecting 3 AsmToken::Identifier after '.aeabi_subsection', a name and 2 + // parameters, e.g.: .aeabi_subsection (1)aeabi_feature_and_bits, (2)optional, + // (3)uleb128 separated by 2 commas. + MCAsmParser &Parser = getParser(); + + bool HasActiveSubsection = true; + std::unique_ptr<MCELFStreamer::AttributeSubSection> ActiveSubsection = + getTargetStreamer().getActiveAtributesSubsection(); + if (nullptr == ActiveSubsection) { + HasActiveSubsection = false; + } + + // Consume the name (subsection name) + StringRef SubsectionName; + AArch64BuildAttributes::VendorID SubsectionNameID; + if (Parser.getTok().is(AsmToken::Identifier)) { + SubsectionName = Parser.getTok().getIdentifier(); + SubsectionNameID = AArch64BuildAttributes::getVendorID(SubsectionName); + } else { + Error(Parser.getTok().getLoc(), "subsection name not found"); + return true; + } + Parser.Lex(); + // consume a comma + // parseComma() return *false* on success, and call Lex(), no need to call + // Lex() again. + if (Parser.parseComma()) { + return true; + } + + // Consume the first parameter (optionality parameter) + AArch64BuildAttributes::SubsectionOptional IsOptional; + // options: optional/required + if (Parser.getTok().is(AsmToken::Identifier)) { + StringRef Optionality = Parser.getTok().getIdentifier(); + IsOptional = AArch64BuildAttributes::getOptionalID(Optionality); + if (AArch64BuildAttributes::OPTIONAL_NOT_FOUND == IsOptional) { + Error(Parser.getTok().getLoc(), + AArch64BuildAttributes::getSubsectionOptionalUnknownError() + ": " + + Optionality); + return true; + } + if (HasActiveSubsection && + (SubsectionName == ActiveSubsection->VendorName)) { + if (IsOptional != ActiveSubsection->IsOptional) { + Error(Parser.getTok().getLoc(), + "optionality mismatch! subsection '" + SubsectionName + + "' already exists with optionality defined as '" + + Twine(ActiveSubsection->IsOptional) + "' and not '" + + Twine(IsOptional) + "' (0: required, 1: optional)"); + return true; + } + } + } else { + Error(Parser.getTok().getLoc(), + "optionality parameter not found, expected required|optinal"); + return true; + } + // Check for possible IsOptional unaccepted values for known subsections + if (AArch64BuildAttributes::AEABI_FEATURE_AND_BITS == SubsectionNameID) { + if (AArch64BuildAttributes::REQUIRED == IsOptional) { + Error(Parser.getTok().getLoc(), + "aeabi_feature_and_bits must be marked as optional"); + return true; + } + } + if (AArch64BuildAttributes::AEABI_PAUTHABI == SubsectionNameID) { + if (AArch64BuildAttributes::OPTIONAL == IsOptional) { + Error(Parser.getTok().getLoc(), + "aeabi_pauthabi must be marked as required"); + return true; + } + } + Parser.Lex(); + // consume a comma + if (Parser.parseComma()) { + return true; + } + + // Consume the second parameter (type parameter) + AArch64BuildAttributes::SubsectionType Type; + if (Parser.getTok().is(AsmToken::Identifier)) { + StringRef Name = Parser.getTok().getIdentifier(); + Type = AArch64BuildAttributes::getTypeID(Name); + if (AArch64BuildAttributes::TYPE_NOT_FOUND == Type) { + Error(Parser.getTok().getLoc(), + AArch64BuildAttributes::getSubsectionTypeUnknownError() + ": " + + Name); + return true; + } + if (HasActiveSubsection && + (SubsectionName == ActiveSubsection->VendorName)) { ---------------- ostannard wrote:
Same bug as above, this is only checking the currently active subsection. https://github.com/llvm/llvm-project/pull/118771 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits