Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion clang/lib/AST/Expr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -774,7 +774,12 @@ std::string PredefinedExpr::ComputeName(PredefinedIdentKind IK,
const FunctionDecl *Decl = FD;
if (const FunctionDecl* Pattern = FD->getTemplateInstantiationPattern())
Decl = Pattern;
const FunctionType *AFT = Decl->getType()->getAs<FunctionType>();

const Type *Ty = Decl->getType().getTypePtrOrNull();
if (!Ty)
return "";

const FunctionType *AFT = Ty->getAs<FunctionType>();
const FunctionProtoType *FT = nullptr;
if (FD->hasWrittenPrototype())
FT = dyn_cast<FunctionProtoType>(AFT);
Expand Down
15 changes: 15 additions & 0 deletions clang/test/SemaCXX/crash-GH121274.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// RUN: %clang_cc1 -std=c++11 -verify %s
// expected-no-diagnostics

// Do not crash when __PRETTY_FUNCTION__ appears in the trailing return type of the lambda
void foo() {
[]() -> decltype(static_cast<const char*>(__PRETTY_FUNCTION__)) {
return nullptr;
}();

#ifdef MS
[]() -> decltype(static_cast<const char*>(__FUNCSIG__)) {
return nullptr;
}();
#endif
}
Loading