From 6f8fc217eaa12bf657be1c6468ed9938d10168b3 Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Thu, 27 Jan 2022 23:06:42 +0100 Subject: Vendor import of llvm-project main llvmorg-14-init-17616-g024a1fab5c35. --- lld/ELF/ScriptParser.cpp | 62 ++++++++++++++++++++++++------------------------ 1 file changed, 31 insertions(+), 31 deletions(-) (limited to 'lld/ELF/ScriptParser.cpp') diff --git a/lld/ELF/ScriptParser.cpp b/lld/ELF/ScriptParser.cpp index d3b0296acab0..7331d1156f27 100644 --- a/lld/ELF/ScriptParser.cpp +++ b/lld/ELF/ScriptParser.cpp @@ -20,7 +20,7 @@ #include "ScriptLexer.h" #include "Symbols.h" #include "Target.h" -#include "lld/Common/Memory.h" +#include "lld/Common/CommonLinkerContext.h" #include "llvm/ADT/SmallString.h" #include "llvm/ADT/StringRef.h" #include "llvm/ADT/StringSet.h" @@ -93,12 +93,12 @@ private: void readSectionAddressType(OutputSection *cmd); OutputSection *readOverlaySectionDescription(); OutputSection *readOutputSectionDescription(StringRef outSec); - std::vector readOverlay(); - std::vector readOutputSectionPhdrs(); + SmallVector readOverlay(); + SmallVector readOutputSectionPhdrs(); std::pair readInputSectionFlags(); InputSectionDescription *readInputSectionDescription(StringRef tok); StringMatcher readFilePatterns(); - std::vector readInputSectionsList(); + SmallVector readInputSectionsList(); InputSectionDescription *readInputSectionRules(StringRef filePattern, uint64_t withFlags, uint64_t withoutFlags); @@ -125,11 +125,11 @@ private: Expr readParenExpr(); // For parsing version script. - std::vector readVersionExtern(); + SmallVector readVersionExtern(); void readAnonymousDeclaration(); void readVersionDeclaration(StringRef verStr); - std::pair, std::vector> + std::pair, SmallVector> readSymbols(); // True if a script being read is in the --sysroot directory. @@ -181,8 +181,8 @@ static ExprValue bitOr(ExprValue a, ExprValue b) { void ScriptParser::readDynamicList() { expect("{"); - std::vector locals; - std::vector globals; + SmallVector locals; + SmallVector globals; std::tie(locals, globals) = readSymbols(); expect(";"); @@ -290,7 +290,7 @@ void ScriptParser::addFile(StringRef s) { SmallString<128> pathData; StringRef path = (config->sysroot + s).toStringRef(pathData); if (sys::fs::exists(path)) - driver->addFile(saver.save(path), /*withLOption=*/false); + driver->addFile(saver().save(path), /*withLOption=*/false); else setError("cannot find " + s + " inside " + config->sysroot); return; @@ -304,7 +304,7 @@ void ScriptParser::addFile(StringRef s) { if (config->sysroot.empty()) driver->addFile(s.substr(1), /*withLOption=*/false); else - driver->addFile(saver.save(config->sysroot + "/" + s.substr(1)), + driver->addFile(saver().save(config->sysroot + "/" + s.substr(1)), /*withLOption=*/false); } else if (s.startswith("-l")) { // Case 3: search in the list of library paths. @@ -327,7 +327,7 @@ void ScriptParser::addFile(StringRef s) { } else { // Finally, search in the list of library paths. if (Optional path = findFromSearchPaths(s)) - driver->addFile(saver.save(*path), /*withLOption=*/true); + driver->addFile(saver().save(*path), /*withLOption=*/true); else setError("unable to find " + s); } @@ -519,7 +519,7 @@ void ScriptParser::readSearchDir() { // sections that use the same virtual memory range and normally would trigger // linker's sections sanity check failures. // https://sourceware.org/binutils/docs/ld/Overlay-Description.html#Overlay-Description -std::vector ScriptParser::readOverlay() { +SmallVector ScriptParser::readOverlay() { // VA and LMA expressions are optional, though for simplicity of // implementation we assume they are not. That is what OVERLAY was designed // for first of all: to allow sections with overlapping VAs at different LMAs. @@ -529,7 +529,7 @@ std::vector ScriptParser::readOverlay() { Expr lmaExpr = readParenExpr(); expect("{"); - std::vector v; + SmallVector v; OutputSection *prev = nullptr; while (!errorCount() && !consume("}")) { // VA is the same for all sections. The LMAs are consecutive in memory @@ -566,7 +566,7 @@ void ScriptParser::readOverwriteSections() { void ScriptParser::readSections() { expect("{"); - std::vector v; + SmallVector v; while (!errorCount() && !consume("}")) { StringRef tok = next(); if (tok == "OVERLAY") { @@ -597,7 +597,7 @@ void ScriptParser::readSections() { else if (!consume("BEFORE")) setError("expected AFTER/BEFORE, but got '" + next() + "'"); StringRef where = next(); - std::vector names; + SmallVector names; for (SectionCommand *cmd : v) if (auto *os = dyn_cast(cmd)) names.push_back(os->name); @@ -672,8 +672,8 @@ SortSectionPolicy ScriptParser::readSortKind() { // is parsed as ".foo", ".bar" with "a.o", and ".baz" with "b.o". // The semantics of that is section .foo in any file, section .bar in // any file but a.o, and section .baz in any file but b.o. -std::vector ScriptParser::readInputSectionsList() { - std::vector ret; +SmallVector ScriptParser::readInputSectionsList() { + SmallVector ret; while (!errorCount() && peek() != ")") { StringMatcher excludeFilePat; if (consume("EXCLUDE_FILE")) { @@ -718,7 +718,7 @@ ScriptParser::readInputSectionRules(StringRef filePattern, uint64_t withFlags, while (!errorCount() && !consume(")")) { SortSectionPolicy outer = readSortKind(); SortSectionPolicy inner = SortSectionPolicy::Default; - std::vector v; + SmallVector v; if (outer != SortSectionPolicy::Default) { expect("("); inner = readSortKind(); @@ -1452,8 +1452,8 @@ Expr ScriptParser::readParenExpr() { return e; } -std::vector ScriptParser::readOutputSectionPhdrs() { - std::vector phdrs; +SmallVector ScriptParser::readOutputSectionPhdrs() { + SmallVector phdrs; while (!errorCount() && peek().startswith(":")) { StringRef tok = next(); phdrs.push_back((tok.size() == 1) ? next() : tok.substr(1)); @@ -1494,8 +1494,8 @@ unsigned ScriptParser::readPhdrType() { // Reads an anonymous version declaration. void ScriptParser::readAnonymousDeclaration() { - std::vector locals; - std::vector globals; + SmallVector locals; + SmallVector globals; std::tie(locals, globals) = readSymbols(); for (const SymbolVersion &pat : locals) config->versionDefinitions[VER_NDX_LOCAL].localPatterns.push_back(pat); @@ -1509,8 +1509,8 @@ void ScriptParser::readAnonymousDeclaration() { // e.g. "VerStr { global: foo; bar; local: *; };". void ScriptParser::readVersionDeclaration(StringRef verStr) { // Read a symbol list. - std::vector locals; - std::vector globals; + SmallVector locals; + SmallVector globals; std::tie(locals, globals) = readSymbols(); // Create a new version definition and add that to the global symbols. @@ -1535,11 +1535,11 @@ bool elf::hasWildcard(StringRef s) { } // Reads a list of symbols, e.g. "{ global: foo; bar; local: *; };". -std::pair, std::vector> +std::pair, SmallVector> ScriptParser::readSymbols() { - std::vector locals; - std::vector globals; - std::vector *v = &globals; + SmallVector locals; + SmallVector globals; + SmallVector *v = &globals; while (!errorCount()) { if (consume("}")) @@ -1554,7 +1554,7 @@ ScriptParser::readSymbols() { } if (consume("extern")) { - std::vector ext = readVersionExtern(); + SmallVector ext = readVersionExtern(); v->insert(v->end(), ext.begin(), ext.end()); } else { StringRef tok = next(); @@ -1570,14 +1570,14 @@ ScriptParser::readSymbols() { // // The last semicolon is optional. E.g. this is OK: // "extern "C++" { ns::*; "f(int, double)" };" -std::vector ScriptParser::readVersionExtern() { +SmallVector ScriptParser::readVersionExtern() { StringRef tok = next(); bool isCXX = tok == "\"C++\""; if (!isCXX && tok != "\"C\"") setError("Unknown language"); expect("{"); - std::vector ret; + SmallVector ret; while (!errorCount() && peek() != "}") { StringRef tok = next(); ret.push_back( -- cgit v1.3