[all-commits] [llvm/llvm-project] 3925fb: nullptr returned from ActOnTag() is not a valid re...

Aaron Ballman via All-commits all-commits at lists.llvm.org
Tue Jan 17 13:04:55 PST 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 3925fbc80019f72bf3f5174736f348acfb5768b0
      https://github.com/llvm/llvm-project/commit/3925fbc80019f72bf3f5174736f348acfb5768b0
  Author: Aaron Ballman <aaron at aaronballman.com>
  Date:   2023-01-17 (Tue, 17 Jan 2023)

  Changed paths:
    M clang/include/clang/Sema/Sema.h
    M clang/lib/Parse/ParseDecl.cpp
    M clang/lib/Sema/SemaDecl.cpp
    M clang/lib/Sema/SemaDeclCXX.cpp
    M clang/lib/Sema/SemaTemplate.cpp
    M clang/test/Parser/cxx-undeclared-identifier.cpp
    M clang/test/Parser/recovery.cpp
    M clang/test/SemaCXX/invalid-template-params.cpp
    M clang/test/SemaCXX/rdar42746401.cpp

  Log Message:
  -----------
  nullptr returned from ActOnTag() is not a valid result

DeclResult tracks two states: valid/invalid and usable/unusable.
Passing a null pointer to the constructor creates a valid but unusable
result and we wanted an invalid result instead. This changes some
functions to return a DeclResult rather than a Decl * to make it harder
to get this incorrect in callers.

Discovered when working on https://reviews.llvm.org/D141280.

Co-authored-by: Haojian Wu <hokein at google.com>
Co-authored-by: Aaron Ballman <aaron at aaronballman.com>

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




More information about the All-commits mailing list