This is an archive of the discontinued LLVM Phabricator instance.

[clang] Fix a crash on invalid auto.
ClosedPublic

Authored by hokein on May 6 2020, 12:40 AM.

Details

Summary

The crash is triggered on accessing a null InitExpr.

For group declaration, e.g. auto c = a, &d = {a};, what's happening:

  1. each VarDecl is built separately during the parsing stage.
  2. perform the semantic analysis (Sema::BuildDeclaratorGroup) to check

whether the type of the two VarDecl is the same, if not mark it as invalid.

in step 1, VarDecl c and d are built, both of them are valid (after D77395),
but d is without the InitExpr attached (under -fno-recovery-ast), crash
happens in step 2 when accessing the source range of d's InitExpr.

Diff Detail

Event Timeline

hokein created this revision.May 6 2020, 12:40 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 6 2020, 12:40 AM
sammccall accepted this revision.May 6 2020, 1:43 AM
This revision is now accepted and ready to land.May 6 2020, 1:43 AM
This revision was automatically updated to reflect the committed changes.