56
56
#include " llvm/Object/IRObjectFile.h"
57
57
#include " llvm/Remarks/HotnessThresholdParser.h"
58
58
#include " llvm/Support/CommandLine.h"
59
+ #include " llvm/Support/SaveAndRestore.h"
59
60
#include " llvm/Support/Compression.h"
60
61
#include " llvm/Support/FileSystem.h"
61
62
#include " llvm/Support/GlobPattern.h"
@@ -322,8 +323,7 @@ void LinkerDriver::addFile(StringRef path, bool withLOption) {
322
323
//
323
324
// All files within the archive get the same group ID to allow mutual
324
325
// references for --warn-backrefs.
325
- bool saved = InputFile::isInGroup;
326
- InputFile::isInGroup = true ;
326
+ SaveAndRestore saved (isInGroup, true );
327
327
for (const std::pair<MemoryBufferRef, uint64_t > &p : members) {
328
328
auto magic = identify_magic (p.first .getBuffer ());
329
329
if (magic == file_magic::elf_relocatable) {
@@ -335,9 +335,8 @@ void LinkerDriver::addFile(StringRef path, bool withLOption) {
335
335
warn (path + " : archive member '" + p.first .getBufferIdentifier () +
336
336
" ' is neither ET_REL nor LLVM bitcode" );
337
337
}
338
- InputFile::isInGroup = saved;
339
- if (!saved)
340
- ++InputFile::nextGroupId;
338
+ if (!saved.get ())
339
+ ++nextGroupId;
341
340
return ;
342
341
}
343
342
case file_magic::elf_shared_object: {
@@ -1934,7 +1933,8 @@ void LinkerDriver::createFiles(opt::InputArgList &args) {
1934
1933
1935
1934
// Iterate over argv to process input files and positional arguments.
1936
1935
std::optional<MemoryBufferRef> defaultScript;
1937
- InputFile::isInGroup = false ;
1936
+ nextGroupId = 0 ;
1937
+ isInGroup = false ;
1938
1938
bool hasInput = false , hasScript = false ;
1939
1939
for (auto *arg : args) {
1940
1940
switch (arg->getOption ().getID ()) {
@@ -2004,30 +2004,30 @@ void LinkerDriver::createFiles(opt::InputArgList &args) {
2004
2004
armCmseImpLib = createObjFile (*mb);
2005
2005
break ;
2006
2006
case OPT_start_group:
2007
- if (InputFile:: isInGroup)
2007
+ if (isInGroup)
2008
2008
error (" nested --start-group" );
2009
- InputFile:: isInGroup = true ;
2009
+ isInGroup = true ;
2010
2010
break ;
2011
2011
case OPT_end_group:
2012
- if (!InputFile:: isInGroup)
2012
+ if (!isInGroup)
2013
2013
error (" stray --end-group" );
2014
- InputFile:: isInGroup = false ;
2015
- ++InputFile:: nextGroupId;
2014
+ isInGroup = false ;
2015
+ ++nextGroupId;
2016
2016
break ;
2017
2017
case OPT_start_lib:
2018
2018
if (inLib)
2019
2019
error (" nested --start-lib" );
2020
- if (InputFile:: isInGroup)
2020
+ if (isInGroup)
2021
2021
error (" may not nest --start-lib in --start-group" );
2022
2022
inLib = true ;
2023
- InputFile:: isInGroup = true ;
2023
+ isInGroup = true ;
2024
2024
break ;
2025
2025
case OPT_end_lib:
2026
2026
if (!inLib)
2027
2027
error (" stray --end-lib" );
2028
2028
inLib = false ;
2029
- InputFile:: isInGroup = false ;
2030
- ++InputFile:: nextGroupId;
2029
+ isInGroup = false ;
2030
+ ++nextGroupId;
2031
2031
break ;
2032
2032
case OPT_push_state:
2033
2033
stack.emplace_back (ctx.arg .asNeeded , ctx.arg .isStatic , inWholeArchive);
0 commit comments