forked from OSchip/llvm-project
Move a helper class out of bugpoint to here.
llvm-svn: 11582
This commit is contained in:
parent
7f059ebd78
commit
2bcf9410de
|
@ -131,6 +131,26 @@ public:
|
|||
return Ret;
|
||||
}
|
||||
};
|
||||
|
||||
/// FileRemover - This class is a simple object meant to be stack allocated.
|
||||
/// If an exception is thrown from a region, the object removes the filename
|
||||
/// specified (if deleteIt is true).
|
||||
///
|
||||
class FileRemover {
|
||||
bool DeleteIt;
|
||||
std::string Filename;
|
||||
public:
|
||||
FileRemover(bool deleteIt, const std::string &filename)
|
||||
: DeleteIt(deleteIt), Filename(filename) {}
|
||||
|
||||
~FileRemover() {
|
||||
if (DeleteIt) removeFile(Filename);
|
||||
}
|
||||
|
||||
/// releaseFile - Take ownership of the file away from the FileRemover so it
|
||||
/// will not be removed when the object is destroyed.
|
||||
void releaseFile() { DeleteIt = false; }
|
||||
};
|
||||
} // End llvm namespace
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue