[all-commits] [llvm/llvm-project] c6e1fd: [clang] Fix a crash on invalid auto.

Haojian Wu via All-commits all-commits at lists.llvm.org
Wed May 6 02:52:39 PDT 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: c6e1fd70fb24d52daff4ec3fca1a89adfe7c2a0b
      https://github.com/llvm/llvm-project/commit/c6e1fd70fb24d52daff4ec3fca1a89adfe7c2a0b
  Author: Haojian Wu <hokein.wu at gmail.com>
  Date:   2020-05-06 (Wed, 06 May 2020)

  Changed paths:
    M clang/lib/Sema/SemaDecl.cpp
    A clang/test/SemaCXX/auto-invalid-init-crash.cpp

  Log Message:
  -----------
  [clang] Fix a crash on invalid auto.

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.

Reviewers: sammccall

Subscribers: cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D79473




More information about the All-commits mailing list