================
@@ -152,7 +152,7 @@ int main(int argc, const char **argv) {
for (auto I = ChangedFiles.begin(), E = ChangedFiles.end(); I != E; ++I)
{
OS << " {\n";
OS << " \"FilePath\": \"" << *I << "\",\n";
- const auto Entry = FileMgr.getFile(*I);
+ auto Entry = FileMgr.getOptionalFileRef(*I);
----------------
benlangmuir wrote:
In cases like this where we immediately dereference the optional, I suggest
either
```c++
auto Entry = llvm::cantFail(FileMgr.getFileRef(*I));
```
or
```c++
auto Entry = FileMgr.getFileRef(*I);
if (!Entry)
llvm::report_fatal_error(Entry.takeError);
```
depending on whether you want to assert the value (cantFail) or want to also
report the error in release builds (report_fatal_error).
The benefit here is that you get the error message if it goes wrong, instead of
just a segfault.
https://github.com/llvm/llvm-project/pull/67838
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits