[llvm-branch-commits] [clang] 8c86197 - clang-import-test: Clean up error output for files that cannot be found
Duncan P. N. Exon Smith via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Fri Dec 11 17:22:02 PST 2020
Author: Duncan P. N. Exon Smith
Date: 2020-12-11T17:07:58-08:00
New Revision: 8c86197de3cba4257f26133e837d64e5f8ece210
URL: https://github.com/llvm/llvm-project/commit/8c86197de3cba4257f26133e837d64e5f8ece210
DIFF: https://github.com/llvm/llvm-project/commit/8c86197de3cba4257f26133e837d64e5f8ece210.diff
LOG: clang-import-test: Clean up error output for files that cannot be found
Pass on the filesystem error string `FileManager::getFileRef` in
`clang-import-test`'s `ParseSource` function. Also include "error:" and
a newline in the output. As a side effect, migrate to the `FileEntryRef`
overload of `SourceManager::createFileID`.
No real functionality change here, just slightly better output on error.
Differential Revision: https://reviews.llvm.org/D92971
Added:
Modified:
clang/test/Import/missing-import/test.c
clang/tools/clang-import-test/clang-import-test.cpp
Removed:
################################################################################
diff --git a/clang/test/Import/missing-import/test.c b/clang/test/Import/missing-import/test.c
index acf6389cc5fc..9a16c2bf4ac8 100644
--- a/clang/test/Import/missing-import/test.c
+++ b/clang/test/Import/missing-import/test.c
@@ -1,5 +1,5 @@
// RUN: not clang-import-test -import %S/Inputs/S.c -expression %s 2>&1 | FileCheck %s
-// CHECK: {{.*}}Couldn't open{{.*}}Inputs/S.c{{.*}}
+// CHECK: error: No such file or directory: {{.*}}Inputs/S.c{{$}}
void expr() {
struct S MyS;
void *MyPtr = &MyS;
diff --git a/clang/tools/clang-import-test/clang-import-test.cpp b/clang/tools/clang-import-test/clang-import-test.cpp
index eca3012957a3..5e84c5f97851 100644
--- a/clang/tools/clang-import-test/clang-import-test.cpp
+++ b/clang/tools/clang-import-test/clang-import-test.cpp
@@ -289,10 +289,11 @@ CIAndOrigins BuildIndirect(CIAndOrigins &CI) {
llvm::Error ParseSource(const std::string &Path, CompilerInstance &CI,
ASTConsumer &Consumer) {
SourceManager &SM = CI.getSourceManager();
- auto FE = CI.getFileManager().getFile(Path);
+ auto FE = CI.getFileManager().getFileRef(Path);
if (!FE) {
return llvm::make_error<llvm::StringError>(
- llvm::Twine("Couldn't open ", Path), std::error_code());
+ llvm::Twine(llvm::toString(FE.takeError())) + ": " + Path,
+ std::error_code());
}
SM.setMainFileID(SM.createFileID(*FE, SourceLocation(), SrcMgr::C_User));
ParseAST(CI.getPreprocessor(), &Consumer, CI.getASTContext());
@@ -360,7 +361,7 @@ int main(int argc, const char **argv) {
for (auto I : Imports) {
llvm::Expected<CIAndOrigins> ImportCI = Parse(I, {}, false, false);
if (auto E = ImportCI.takeError()) {
- llvm::errs() << llvm::toString(std::move(E));
+ llvm::errs() << "error: " << llvm::toString(std::move(E)) << "\n";
exit(-1);
}
ImportCIs.push_back(std::move(*ImportCI));
@@ -379,7 +380,7 @@ int main(int argc, const char **argv) {
Parse(Expression, (Direct && !UseOrigins) ? ImportCIs : IndirectCIs,
DumpAST, DumpIR);
if (auto E = ExpressionCI.takeError()) {
- llvm::errs() << llvm::toString(std::move(E));
+ llvm::errs() << "error: " << llvm::toString(std::move(E)) << "\n";
exit(-1);
}
Forget(*ExpressionCI, (Direct && !UseOrigins) ? ImportCIs : IndirectCIs);
More information about the llvm-branch-commits
mailing list