forked from iowastateuniversity-programanalysis/hydrogen
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathModule.cpp
More file actions
28 lines (28 loc) · 881 Bytes
/
Module.cpp
File metadata and controls
28 lines (28 loc) · 881 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
/**
* @author Ashwin K J
* @file
* Implementing Module.hpp
*/
#include "Module.hpp"
namespace hydrogen_framework {
bool Module::setModule(int ver, std::string file) {
modVersion = ver;
llvm::StringRef modulePath(file);
llvm::SMDiagnostic error;
modPtr = llvm::parseIRFile(modulePath, error, modContext);
/* Parsing Error handling */
if (!modPtr) {
std::string errorMessage;
llvm::raw_string_ostream output(errorMessage);
/* error.print("Error in parsing the file ", output); */
std::cerr << "Error in parsing the " << file << "\n";
return false;
} // End check for modPtr
/* Verifying Module */
if (llvm::verifyModule(*modPtr, &llvm::errs()) != 0) {
std::cerr << "Error in verifying the Module : " << file << "\n";
return false;
} // End check for verifyModule
return true;
} // End setModule
} // namespace hydrogen_framework