Merge pull request #834 from emankov/master

[HIPIFY] LLVM compatibility
This commit is contained in:
Evgeny Mankov
2018-12-28 15:13:36 +03:00
committed by GitHub
3 changed files with 15 additions and 3 deletions
+9
View File
@@ -94,4 +94,13 @@ clang::SourceLocation getEndLoc(const clang::TypeLoc& typeLoc) {
#endif
}
std::error_code real_path(const Twine &path, SmallVectorImpl<char> &output,
bool expand_tilde) {
#if LLVM_VERSION_MAJOR < 5
return sys::fs::make_absolute(path, output);
#else
return sys::fs::real_path(path, output, expand_tilde);
#endif
}
} // namespace llcompat
+3
View File
@@ -78,4 +78,7 @@ void EnterPreprocessorTokenStream(clang::Preprocessor& _pp,
size_t len,
bool DisableMacroExpansion);
std::error_code real_path(const Twine &path, SmallVectorImpl<char> &output,
bool expand_tilde = false);
} // namespace llcompat
+3 -3
View File
@@ -46,7 +46,7 @@ std::string getAbsoluteDirectory(const std::string& sDir, std::error_code& EC,
return sDir;
}
SmallString<256> dirAbsPath;
EC = sys::fs::real_path(sDir, dirAbsPath, true);
EC = llcompat::real_path(sDir, dirAbsPath, true);
if (!EC && sys::fs::is_regular_file(dirAbsPath)) {
llvm::errs() << "\n" << sHipify << sError << sDir << " is not a directory\n";
EC = std::error_code(static_cast<int>(std::errc::not_a_directory), std::generic_category());
@@ -58,7 +58,7 @@ std::string getAbsoluteDirectory(const std::string& sDir, std::error_code& EC,
llvm::errs() << "\n" << sHipify << sError << EC.message() << ": " << sDirType << " directory: " << sDir << "\n";
return "";
}
EC = sys::fs::real_path(sDir, dirAbsPath, true);
EC = llcompat::real_path(sDir, dirAbsPath, true);
if (EC) {
llvm::errs() << "\n" << sHipify << sError << EC.message() << ": " << sDirType << " directory: " << sDir << "\n";
return "";
@@ -137,7 +137,7 @@ int main(int argc, const char **argv) {
// Create a copy of the file to work on. When we're done, we'll move this onto the
// output (which may mean overwriting the input, if we're in-place).
// Should we fail for some reason, we'll just leak this file and not corrupt the input.
EC = sys::fs::real_path(src, sourceAbsPath, true);
EC = llcompat::real_path(src, sourceAbsPath, true);
if (EC) {
llvm::errs() << "\n" << sHipify << sError << EC.message() << ": " << src << "\n";
Result = 1;