llvm.org GIT mirror llvm / f1e3285
Move a helper class out of bugpoint to here. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11582 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Lattner 16 years ago
2 changed file(s) with 40 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
130130 return Ret;
131131 }
132132 };
133
134 /// FileRemover - This class is a simple object meant to be stack allocated.
135 /// If an exception is thrown from a region, the object removes the filename
136 /// specified (if deleteIt is true).
137 ///
138 class FileRemover {
139 bool DeleteIt;
140 std::string Filename;
141 public:
142 FileRemover(bool deleteIt, const std::string &filename)
143 : DeleteIt(deleteIt), Filename(filename) {}
144
145 ~FileRemover() {
146 if (DeleteIt) removeFile(Filename);
147 }
148
149 /// releaseFile - Take ownership of the file away from the FileRemover so it
150 /// will not be removed when the object is destroyed.
151 void releaseFile() { DeleteIt = false; }
152 };
133153 } // End llvm namespace
134154
135155 #endif
130130 return Ret;
131131 }
132132 };
133
134 /// FileRemover - This class is a simple object meant to be stack allocated.
135 /// If an exception is thrown from a region, the object removes the filename
136 /// specified (if deleteIt is true).
137 ///
138 class FileRemover {
139 bool DeleteIt;
140 std::string Filename;
141 public:
142 FileRemover(bool deleteIt, const std::string &filename)
143 : DeleteIt(deleteIt), Filename(filename) {}
144
145 ~FileRemover() {
146 if (DeleteIt) removeFile(Filename);
147 }
148
149 /// releaseFile - Take ownership of the file away from the FileRemover so it
150 /// will not be removed when the object is destroyed.
151 void releaseFile() { DeleteIt = false; }
152 };
133153 } // End llvm namespace
134154
135155 #endif