nullptr returned from ActOnTag() is not a valid result
authorAaron Ballman <aaron@aaronballman.com>
Tue, 17 Jan 2023 21:00:46 +0000 (16:00 -0500)
committerAaron Ballman <aaron@aaronballman.com>
Tue, 17 Jan 2023 21:04:35 +0000 (16:04 -0500)
commit3925fbc80019f72bf3f5174736f348acfb5768b0
treebe061c108fc30747fc108d4ec1055590400026a1
parentdf950a04d5add13a649ecbd9feb858d64ad455ae
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@google.com>
Co-authored-by: Aaron Ballman <aaron@aaronballman.com>
Differential Revision: https://reviews.llvm.org/D141580
clang/include/clang/Sema/Sema.h
clang/lib/Parse/ParseDecl.cpp
clang/lib/Sema/SemaDecl.cpp
clang/lib/Sema/SemaDeclCXX.cpp
clang/lib/Sema/SemaTemplate.cpp
clang/test/Parser/cxx-undeclared-identifier.cpp
clang/test/Parser/recovery.cpp
clang/test/SemaCXX/invalid-template-params.cpp
clang/test/SemaCXX/rdar42746401.cpp