Index: test/tools/llvm-ar/mri-delete.test =================================================================== --- test/tools/llvm-ar/mri-delete.test +++ test/tools/llvm-ar/mri-delete.test @@ -3,6 +3,10 @@ RUN: echo "create %t.ar" > %t.mri RUN: echo "addmod %t.o" >> %t.mri +RUN: echo "; comment" >> %t.mri +RUN: echo " ;comment" >> %t.mri +RUN: echo "* comment" >> %t.mri +RUN: echo " *comment" >> %t.mri RUN: echo "addmod %S/Inputs/elf.yaml" >> %t.mri RUN: echo "delete %t.o" >> %t.mri RUN: echo "save" >> %t.mri Index: tools/llvm-ar/llvm-ar.cpp =================================================================== --- tools/llvm-ar/llvm-ar.cpp +++ tools/llvm-ar/llvm-ar.cpp @@ -807,10 +807,13 @@ for (line_iterator I(Ref, /*SkipBlanks*/ true, ';'), E; I != E; ++I) { StringRef Line = *I; StringRef CommandStr, Rest; + Line = Line.trim(); std::tie(CommandStr, Rest) = Line.split(' '); Rest = Rest.trim(); if (!Rest.empty() && Rest.front() == '"' && Rest.back() == '"') Rest = Rest.drop_front().drop_back(); + if (CommandStr.startswith(";") || CommandStr.startswith("*")) + continue; auto Command = StringSwitch(CommandStr.lower()) .Case("addlib", MRICommand::AddLib) .Case("addmod", MRICommand::AddMod)