@@ -636,8 +636,9 @@ struct CheckString {
636
636
// /
637
637
// / \param PreserveHorizontal Don't squash consecutive horizontal whitespace
638
638
// / characters to a single space.
639
- static MemoryBuffer *CanonicalizeInputFile (std::unique_ptr<MemoryBuffer> MB,
640
- bool PreserveHorizontal) {
639
+ static std::unique_ptr<MemoryBuffer>
640
+ CanonicalizeInputFile (std::unique_ptr<MemoryBuffer> MB,
641
+ bool PreserveHorizontal) {
641
642
SmallString<128 > NewFile;
642
643
NewFile.reserve (MB->getBufferSize ());
643
644
@@ -662,8 +663,8 @@ static MemoryBuffer *CanonicalizeInputFile(std::unique_ptr<MemoryBuffer> MB,
662
663
++Ptr ;
663
664
}
664
665
665
- return MemoryBuffer::getMemBufferCopy (NewFile. str (),
666
- MB->getBufferIdentifier ());
666
+ return std::unique_ptr<MemoryBuffer>(
667
+ MemoryBuffer::getMemBufferCopy (NewFile. str (), MB->getBufferIdentifier () ));
667
668
}
668
669
669
670
static bool IsPartOfWord (char c) {
@@ -838,25 +839,25 @@ static bool ReadCheckFile(SourceMgr &SM,
838
839
839
840
// If we want to canonicalize whitespace, strip excess whitespace from the
840
841
// buffer containing the CHECK lines. Remove DOS style line endings.
841
- MemoryBuffer *F = CanonicalizeInputFile (std::move (FileOrErr.get ()),
842
- NoCanonicalizeWhiteSpace);
843
-
844
- SM.AddNewSourceBuffer (F, SMLoc ());
842
+ std::unique_ptr<MemoryBuffer> F =
843
+ CanonicalizeInputFile (std::move (*FileOrErr), NoCanonicalizeWhiteSpace);
845
844
846
845
// Find all instances of CheckPrefix followed by : in the file.
847
846
StringRef Buffer = F->getBuffer ();
848
847
848
+ SM.AddNewSourceBuffer (std::move (F), SMLoc ());
849
+
849
850
std::vector<Pattern> ImplicitNegativeChecks;
850
851
for (const auto &PatternString : ImplicitCheckNot) {
851
852
// Create a buffer with fake command line content in order to display the
852
853
// command line option responsible for the specific implicit CHECK-NOT.
853
854
std::string Prefix = std::string (" -" ) + ImplicitCheckNot.ArgStr + " ='" ;
854
855
std::string Suffix = " '" ;
855
- MemoryBuffer * CmdLine = MemoryBuffer::getMemBufferCopy (
856
- Prefix + PatternString + Suffix, " command line" );
856
+ std::unique_ptr< MemoryBuffer> CmdLine ( MemoryBuffer::getMemBufferCopy (
857
+ Prefix + PatternString + Suffix, " command line" )) ;
857
858
StringRef PatternInBuffer =
858
859
CmdLine->getBuffer ().substr (Prefix.size (), PatternString.size ());
859
- SM.AddNewSourceBuffer (CmdLine, SMLoc ());
860
+ SM.AddNewSourceBuffer (std::move ( CmdLine) , SMLoc ());
860
861
861
862
ImplicitNegativeChecks.push_back (Pattern (Check::CheckNot));
862
863
ImplicitNegativeChecks.back ().ParsePattern (PatternInBuffer,
@@ -1272,18 +1273,18 @@ int main(int argc, char **argv) {
1272
1273
1273
1274
// Remove duplicate spaces in the input file if requested.
1274
1275
// Remove DOS style line endings.
1275
- MemoryBuffer *F =
1276
- CanonicalizeInputFile (std::move (File), NoCanonicalizeWhiteSpace);
1277
-
1278
- SM.AddNewSourceBuffer (F, SMLoc ());
1279
-
1280
- // / VariableTable - This holds all the current filecheck variables.
1281
- StringMap<StringRef> VariableTable;
1276
+ std::unique_ptr<MemoryBuffer> F =
1277
+ CanonicalizeInputFile (std::move (File), NoCanonicalizeWhiteSpace);
1282
1278
1283
1279
// Check that we have all of the expected strings, in order, in the input
1284
1280
// file.
1285
1281
StringRef Buffer = F->getBuffer ();
1286
1282
1283
+ SM.AddNewSourceBuffer (std::move (F), SMLoc ());
1284
+
1285
+ // / VariableTable - This holds all the current filecheck variables.
1286
+ StringMap<StringRef> VariableTable;
1287
+
1287
1288
bool hasError = false ;
1288
1289
1289
1290
unsigned i = 0 , j = 0 , e = CheckStrings.size ();
0 commit comments