Files
clang-p2996/clang/test/CXX/drs/dr177x.cpp
David Blaikie aee4925507 Recommit: Compress formatting of array type names (int [4] -> int[4])
Based on post-commit review discussion on
2bd8493847 with Richard Smith.

Other uses of forcing HasEmptyPlaceHolder to false seem OK to me -
they're all around pointer/reference types where the pointer/reference
token will appear at the rightmost side of the left side of the type
name, so they make nested types (eg: the "int" in "int *") behave as
though there is a non-empty placeholder (because the "*" is essentially
the placeholder as far as the "int" is concerned).

This was originally committed in 277623f4d5

Reverted in f9ad1d1c77 due to breakages
outside of clang - lldb seems to have some strange/strong dependence on
"char [N]" versus "char[N]" when printing strings (not due to that name
appearing in DWARF, but probably due to using clang to stringify type
names) that'll need to be addressed, plus a few other odds and ends in
other subprojects (clang-tools-extra, compiler-rt, etc).
2021-10-21 11:34:43 -07:00

80 lines
3.0 KiB
C++

// RUN: %clang_cc1 -std=c++98 %s -fexceptions -fcxx-exceptions -pedantic-errors -ast-dump | FileCheck %s
// RUN: %clang_cc1 -std=c++11 %s -fexceptions -fcxx-exceptions -pedantic-errors -ast-dump | FileCheck %s --check-prefixes=CHECK,CXX11
// RUN: %clang_cc1 -std=c++14 %s -fexceptions -fcxx-exceptions -pedantic-errors -ast-dump | FileCheck %s --check-prefixes=CHECK,CXX11,CXX14
// RUN: %clang_cc1 -std=c++1z %s -fexceptions -fcxx-exceptions -pedantic-errors -ast-dump | FileCheck %s --check-prefixes=CHECK,CXX11,CXX14
// RUN: %clang_cc1 -std=c++1z %s -fexceptions -fcxx-exceptions -pedantic-errors -triple i386-windows-pc -ast-dump | FileCheck %s --check-prefixes=CHECK,CXX11,CXX14
namespace dr1772 { // dr1772: 14
// __func__ in a lambda should name operator(), not the containing function.
// CHECK: NamespaceDecl{{.+}}dr1772
#if __cplusplus >= 201103L
auto x = []() { __func__; };
// CXX11: LambdaExpr
// CXX11: CXXRecordDecl
// CXX11: CXXMethodDecl{{.+}} operator() 'void () {{.*}}const'
// CXX11-NEXT: CompoundStmt
// CXX11-NEXT: PredefinedExpr{{.+}} 'const char[11]' lvalue __func__
// CXX11-NEXT: StringLiteral{{.+}} 'const char[11]' lvalue "operator()"
void func() {
// CXX11: FunctionDecl{{.+}} func
(void)[]() { __func__; };
// CXX11-NEXT: CompoundStmt
// CXX11: LambdaExpr
// CXX11: CXXRecordDecl
// CXX11: CXXMethodDecl{{.+}} operator() 'void () {{.*}}const'
// CXX11-NEXT: CompoundStmt
// CXX11-NEXT: PredefinedExpr{{.+}} 'const char[11]' lvalue __func__
// CXX11-NEXT: StringLiteral{{.+}} 'const char[11]' lvalue "operator()"
}
#endif // __cplusplus >= 201103L
}
namespace dr1779 { // dr1779: 14
// __func__ in a function template, member function template, or generic
// lambda should have a dependent type.
// CHECK: NamespaceDecl{{.+}}dr1779
template<typename T>
void FuncTemplate() {
__func__;
// CHECK: FunctionDecl{{.+}} FuncTemplate
// CHECK-NEXT: CompoundStmt
// CHECK-NEXT: PredefinedExpr{{.+}} '<dependent type>' lvalue __func__
}
template<typename T>
class ClassTemplate {
// CHECK: ClassTemplateDecl{{.+}} ClassTemplate
void MemFunc() {
// CHECK: CXXMethodDecl{{.+}} MemFunc 'void (){{.*}}'
// CHECK-NEXT: CompoundStmt
// CHECK-NEXT: PredefinedExpr{{.+}} '<dependent type>' lvalue __func__
__func__;
}
void OutOfLineMemFunc();
};
template <typename T> void ClassTemplate<T>::OutOfLineMemFunc() {
// CHECK: CXXMethodDecl{{.+}}parent{{.+}} OutOfLineMemFunc 'void (){{.*}}'
// CHECK-NEXT: CompoundStmt
// CHECK-NEXT: PredefinedExpr{{.+}} '<dependent type>' lvalue __func__
__func__;
}
#if __cplusplus >= 201402L
void contains_generic_lambda() {
// CXX14: FunctionDecl{{.+}}contains_generic_lambda
// CXX14: LambdaExpr
// CXX14: CXXRecordDecl
// CXX14: CXXMethodDecl{{.+}} operator() 'auto (auto) {{.*}}const'
// CXX14-NEXT: ParmVarDecl
// CXX14-NEXT: CompoundStmt
// CXX14-NEXT: PredefinedExpr{{.+}} '<dependent type>' lvalue __func__
(void)[](auto x) {
__func__;
};
}
#endif // __cplusplus >= 201402L
}