[PATCH] D92971: clang-import-test: Clean up error output for files that cannot be found

Duncan P. N. Exon Smith via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Dec 11 17:17:33 PST 2020


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8c86197de3cb: clang-import-test: Clean up error output for files that cannot be found (authored by dexonsmith).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92971/new/

https://reviews.llvm.org/D92971

Files:
  clang/test/Import/missing-import/test.c
  clang/tools/clang-import-test/clang-import-test.cpp


Index: clang/tools/clang-import-test/clang-import-test.cpp
===================================================================
--- clang/tools/clang-import-test/clang-import-test.cpp
+++ clang/tools/clang-import-test/clang-import-test.cpp
@@ -289,10 +289,11 @@
 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 @@
   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 @@
       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);
Index: clang/test/Import/missing-import/test.c
===================================================================
--- clang/test/Import/missing-import/test.c
+++ 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;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D92971.311340.patch
Type: text/x-patch
Size: 2137 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20201212/50eafa37/attachment.bin>


More information about the cfe-commits mailing list