diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2014-08-26 17:29:46 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2014-08-26 17:29:46 +0000 |
commit | d233b06afc0dddb769f0b548fcb1eadbbf5c74c8 (patch) | |
tree | 88ed3fc6613ec01d266c1bc875fbb27d2ccd1363 /llvm/tools/llvm-diff/llvm-diff.cpp | |
parent | f76a89129982e346458e7830822c6d1403ea1cbd (diff) | |
download | bcm5719-llvm-d233b06afc0dddb769f0b548fcb1eadbbf5c74c8.tar.gz bcm5719-llvm-d233b06afc0dddb769f0b548fcb1eadbbf5c74c8.zip |
Return a std::unique_ptr from the IRReader.h functions. NFC.
llvm-svn: 216466
Diffstat (limited to 'llvm/tools/llvm-diff/llvm-diff.cpp')
-rw-r--r-- | llvm/tools/llvm-diff/llvm-diff.cpp | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/llvm/tools/llvm-diff/llvm-diff.cpp b/llvm/tools/llvm-diff/llvm-diff.cpp index f70219eaf54..ae58f5caa91 100644 --- a/llvm/tools/llvm-diff/llvm-diff.cpp +++ b/llvm/tools/llvm-diff/llvm-diff.cpp @@ -32,21 +32,22 @@ using namespace llvm; /// Reads a module from a file. On error, messages are written to stderr /// and null is returned. -static Module *ReadModule(LLVMContext &Context, StringRef Name) { +static std::unique_ptr<Module> readModule(LLVMContext &Context, + StringRef Name) { SMDiagnostic Diag; - Module *M = ParseIRFile(Name, Diag, Context); + std::unique_ptr<Module> M = parseIRFile(Name, Diag, Context); if (!M) Diag.print("llvm-diff", errs()); return M; } -static void diffGlobal(DifferenceEngine &Engine, Module *L, Module *R, +static void diffGlobal(DifferenceEngine &Engine, Module &L, Module &R, StringRef Name) { // Drop leading sigils from the global name. if (Name.startswith("@")) Name = Name.substr(1); - Function *LFn = L->getFunction(Name); - Function *RFn = R->getFunction(Name); + Function *LFn = L.getFunction(Name); + Function *RFn = R.getFunction(Name); if (LFn && RFn) Engine.diff(LFn, RFn); else if (!LFn && !RFn) @@ -72,8 +73,8 @@ int main(int argc, char **argv) { LLVMContext Context; // Load both modules. Die if that fails. - Module *LModule = ReadModule(Context, LeftFilename); - Module *RModule = ReadModule(Context, RightFilename); + std::unique_ptr<Module> LModule = readModule(Context, LeftFilename); + std::unique_ptr<Module> RModule = readModule(Context, RightFilename); if (!LModule || !RModule) return 1; DiffConsumer Consumer; @@ -82,15 +83,12 @@ int main(int argc, char **argv) { // If any global names were given, just diff those. if (!GlobalsToCompare.empty()) { for (unsigned I = 0, E = GlobalsToCompare.size(); I != E; ++I) - diffGlobal(Engine, LModule, RModule, GlobalsToCompare[I]); + diffGlobal(Engine, *LModule, *RModule, GlobalsToCompare[I]); // Otherwise, diff everything in the module. } else { - Engine.diff(LModule, RModule); + Engine.diff(LModule.get(), RModule.get()); } - delete LModule; - delete RModule; - return Consumer.hadDifferences(); } |