This revision was landed with ongoing or failed builds. This revision was automatically updated to reflect the committed changes. Closed by commit rG21dfe482e13e: [Clang] Fix assert in Sema::LookupTemplateName so that it does not attempt an… (authored by shafik). Herald added a project: clang.
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D132712/new/ https://reviews.llvm.org/D132712 Files: clang/docs/ReleaseNotes.rst clang/lib/Sema/SemaTemplate.cpp clang/test/SemaCXX/member-expr.cpp Index: clang/test/SemaCXX/member-expr.cpp =================================================================== --- clang/test/SemaCXX/member-expr.cpp +++ clang/test/SemaCXX/member-expr.cpp @@ -228,3 +228,19 @@ .i; // expected-error {{member reference type 'S *' is a pointer; did you mean to use '->'}} } } + +namespace LookupTemplateNameAssert { +void f() {} + +typedef int at[]; +const at& f2(){} + +void g() { + f().junk<int>(); // expected-error {{member reference base type 'void' is not a structure or union}} +// expected-error@-1 {{expected '(' for function-style cast or type construction}} +// expected-error@-2 {{expected expression}} + f2().junk<int>(); // expected-error {{member reference base type 'const at' (aka 'const int[]') is not a structure or union}} +// expected-error@-1 {{expected '(' for function-style cast or type construction}} +// expected-error@-2 {{expected expression}} +} +} Index: clang/lib/Sema/SemaTemplate.cpp =================================================================== --- clang/lib/Sema/SemaTemplate.cpp +++ clang/lib/Sema/SemaTemplate.cpp @@ -399,6 +399,7 @@ LookupCtx = computeDeclContext(ObjectType); IsDependent = !LookupCtx && ObjectType->isDependentType(); assert((IsDependent || !ObjectType->isIncompleteType() || + !ObjectType->getAs<TagType>() || ObjectType->castAs<TagType>()->isBeingDefined()) && "Caller should have completed object type"); Index: clang/docs/ReleaseNotes.rst =================================================================== --- clang/docs/ReleaseNotes.rst +++ clang/docs/ReleaseNotes.rst @@ -81,6 +81,9 @@ - Fix a crash when generating code coverage information for an ``if consteval`` statement. This fixes `Issue 57377 <https://github.com/llvm/llvm-project/issues/57377>`_. +- Fix assert that triggers a crash during template name lookup when a type was + incomplete but was not also a TagType. This fixes + `Issue 57387 <https://github.com/llvm/llvm-project/issues/57387>`_. Improvements to Clang's diagnostics
Index: clang/test/SemaCXX/member-expr.cpp =================================================================== --- clang/test/SemaCXX/member-expr.cpp +++ clang/test/SemaCXX/member-expr.cpp @@ -228,3 +228,19 @@ .i; // expected-error {{member reference type 'S *' is a pointer; did you mean to use '->'}} } } + +namespace LookupTemplateNameAssert { +void f() {} + +typedef int at[]; +const at& f2(){} + +void g() { + f().junk<int>(); // expected-error {{member reference base type 'void' is not a structure or union}} +// expected-error@-1 {{expected '(' for function-style cast or type construction}} +// expected-error@-2 {{expected expression}} + f2().junk<int>(); // expected-error {{member reference base type 'const at' (aka 'const int[]') is not a structure or union}} +// expected-error@-1 {{expected '(' for function-style cast or type construction}} +// expected-error@-2 {{expected expression}} +} +} Index: clang/lib/Sema/SemaTemplate.cpp =================================================================== --- clang/lib/Sema/SemaTemplate.cpp +++ clang/lib/Sema/SemaTemplate.cpp @@ -399,6 +399,7 @@ LookupCtx = computeDeclContext(ObjectType); IsDependent = !LookupCtx && ObjectType->isDependentType(); assert((IsDependent || !ObjectType->isIncompleteType() || + !ObjectType->getAs<TagType>() || ObjectType->castAs<TagType>()->isBeingDefined()) && "Caller should have completed object type"); Index: clang/docs/ReleaseNotes.rst =================================================================== --- clang/docs/ReleaseNotes.rst +++ clang/docs/ReleaseNotes.rst @@ -81,6 +81,9 @@ - Fix a crash when generating code coverage information for an ``if consteval`` statement. This fixes `Issue 57377 <https://github.com/llvm/llvm-project/issues/57377>`_. +- Fix assert that triggers a crash during template name lookup when a type was + incomplete but was not also a TagType. This fixes + `Issue 57387 <https://github.com/llvm/llvm-project/issues/57387>`_. Improvements to Clang's diagnostics
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits