Page MenuHomePhabricator

[clang][Frontend] Add missing error handling
ClosedPublic

Authored by LemonBoy on Apr 22 2020, 11:35 AM.

Details

Summary

Some early errors during the ASTUnit creation were not transferred to the FailedParseDiagnostic so when the code in LoadFromCommandLine swaps its content with the content of StoredDiagnostics they cannot be retrieved by the user in any way.

Diff Detail

Event Timeline

LemonBoy created this revision.Apr 22 2020, 11:35 AM
LemonBoy updated this revision to Diff 259374.Apr 22 2020, 1:08 PM

Fix a C&P error in the attached test case.

andrewrk accepted this revision.Sep 18 2020, 1:10 AM
andrewrk added a subscriber: andrewrk.

ping?

This revision is now accepted and ready to land.Sep 18 2020, 1:10 AM

Ping with some more reviewers, hoping to land this in time for LLVM 99.

Perhaps this'd be more robust with ScopeExit? ( https://llvm.org/doxygen/ScopeExit_8h_source.html )

Perhaps this'd be more robust with ScopeExit?

Not really, OnError is not executed when/if the function succeeds.

Perhaps this'd be more robust with ScopeExit?

Not really, OnError is not executed when/if the function succeeds.

Ah, sorry - ScopeExit has a 'release()' function intended to disengage it/disable the execution of the payload.

The use would often look something like:

auto x = make_scope_exit(...);
if (failed())
  return fail;
if (failed())
  return fail;
x.release();
return success;
LemonBoy updated this revision to Diff 297959.Oct 13 2020, 2:29 PM

Use ScopeExit instead of a bare lambda.

dblaikie accepted this revision.Oct 13 2020, 5:38 PM
dblaikie added inline comments.
clang/lib/Frontend/ASTUnit.cpp
1156–1160

You can remove these braces now - since it's a superfluous change here now there's no need to add an extra function call.

1216–1220

Skip the braces here, since it's a single-line scope.

LemonBoy updated this revision to Diff 298133.Oct 14 2020, 6:01 AM
dexonsmith resigned from this revision.Oct 19 2020, 7:06 PM
dblaikie accepted this revision.Oct 19 2020, 11:36 PM

Looks good to me - thanks!

Looks good to me - thanks!

Great! Can you please commit this for me as I have no commit access?

This revision was automatically updated to reflect the committed changes.