Skip to content

Commit 564c6ad

Browse files
authored
merge main into amd-staging (llvm#4365)
2 parents 310a680 + 40a74d7 commit 564c6ad

File tree

18 files changed

+61
-414
lines changed

18 files changed

+61
-414
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,9 @@ AST Dumping Potentially Breaking Changes
123123

124124
``__atomic_test_and_set(p, 0)``
125125

126+
- Pretty-printing of templates with inherited (i.e. specified in a previous
127+
redeclaration) default arguments has been fixed.
128+
126129
Clang Frontend Potentially Breaking Changes
127130
-------------------------------------------
128131
- Members of anonymous unions/structs are now injected as ``IndirectFieldDecl``

clang/lib/AST/DeclPrinter.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1894,7 +1894,7 @@ void DeclPrinter::VisitTemplateTypeParmDecl(const TemplateTypeParmDecl *TTP) {
18941894
Out << TTP->getDeclName();
18951895
}
18961896

1897-
if (TTP->hasDefaultArgument()) {
1897+
if (TTP->hasDefaultArgument() && !TTP->defaultArgumentWasInherited()) {
18981898
Out << " = ";
18991899
TTP->getDefaultArgument().getArgument().print(Policy, Out,
19001900
/*IncludeType=*/false);
@@ -1909,7 +1909,7 @@ void DeclPrinter::VisitNonTypeTemplateParmDecl(
19091909
Policy.CleanUglifiedParameters ? II->deuglifiedName() : II->getName();
19101910
printDeclType(NTTP->getType(), Name, NTTP->isParameterPack());
19111911

1912-
if (NTTP->hasDefaultArgument()) {
1912+
if (NTTP->hasDefaultArgument() && !NTTP->defaultArgumentWasInherited()) {
19131913
Out << " = ";
19141914
NTTP->getDefaultArgument().getArgument().print(Policy, Out,
19151915
/*IncludeType=*/false);

clang/test/AST/ast-print-record-decl.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,9 +290,9 @@ KW DeclGroupInMemberList {
290290
// A tag decl group in the tag decl's own member list is exercised in
291291
// defSelfRef above.
292292

293+
#ifdef __cplusplus
293294

294295
// Check out-of-line record definition
295-
#ifdef __cplusplus
296296
// PRINT-CXX-NEXT: [[KW]] OutOfLineRecord {
297297
KW OutOfLineRecord {
298298
// PRINT-CXX-NEXT: [[KW]] Inner
@@ -304,4 +304,15 @@ KW OutOfLineRecord {
304304
KW OutOfLineRecord::Inner {
305305
// PRINT-CXX-NEXT: };
306306
};
307+
308+
// PRINT-CXX-NEXT: template <typename, typename = int> [[KW]] SmearedTypeDefArgs;
309+
template <typename, typename = int> KW SmearedTypeDefArgs;
310+
// PRINT-CXX-NEXT: template <typename = int, typename> [[KW]] SmearedTypeDefArgs;
311+
template <typename = int, typename> KW SmearedTypeDefArgs;
312+
313+
// PRINT-CXX-NEXT: template <int, int = 0> [[KW]] SmearedNTTPDefArgs;
314+
template <int, int = 0> KW SmearedNTTPDefArgs;
315+
// PRINT-CXX-NEXT: template <int = 0, int> [[KW]] SmearedNTTPDefArgs;
316+
template <int = 0, int> KW SmearedNTTPDefArgs;
317+
307318
#endif

compiler-rt/lib/asan/asan_interceptors.cpp

Lines changed: 3 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -58,20 +58,13 @@ namespace __asan {
5858

5959
static inline uptr MaybeRealStrnlen(const char *s, uptr maxlen) {
6060
#if SANITIZER_INTERCEPT_STRNLEN
61-
if (REAL(strnlen))
61+
if (REAL(strnlen)) {
6262
return REAL(strnlen)(s, maxlen);
63-
# endif
63+
}
64+
#endif
6465
return internal_strnlen(s, maxlen);
6566
}
6667

67-
static inline uptr MaybeRealWcsnlen(const wchar_t* s, uptr maxlen) {
68-
# if SANITIZER_INTERCEPT_WCSNLEN
69-
if (REAL(wcsnlen))
70-
return REAL(wcsnlen)(s, maxlen);
71-
# endif
72-
return internal_wcsnlen(s, maxlen);
73-
}
74-
7568
void SetThreadName(const char *name) {
7669
AsanThread *t = GetCurrentThread();
7770
if (t)
@@ -578,20 +571,6 @@ INTERCEPTOR(char *, strcpy, char *to, const char *from) {
578571
return REAL(strcpy)(to, from);
579572
}
580573

581-
INTERCEPTOR(wchar_t*, wcscpy, wchar_t* to, const wchar_t* from) {
582-
void* ctx;
583-
ASAN_INTERCEPTOR_ENTER(ctx, wcscpy);
584-
if (!TryAsanInitFromRtl())
585-
return REAL(wcscpy)(to, from);
586-
if (flags()->replace_str) {
587-
uptr size = (internal_wcslen(from) + 1) * sizeof(wchar_t);
588-
CHECK_RANGES_OVERLAP("wcscpy", to, size, from, size);
589-
ASAN_READ_RANGE(ctx, from, size);
590-
ASAN_WRITE_RANGE(ctx, to, size);
591-
}
592-
return REAL(wcscpy)(to, from);
593-
}
594-
595574
// Windows doesn't always define the strdup identifier,
596575
// and when it does it's a macro defined to either _strdup
597576
// or _strdup_dbg, _strdup_dbg ends up calling _strdup, so
@@ -655,20 +634,6 @@ INTERCEPTOR(char*, strncpy, char *to, const char *from, usize size) {
655634
return REAL(strncpy)(to, from, size);
656635
}
657636

658-
INTERCEPTOR(wchar_t*, wcsncpy, wchar_t* to, const wchar_t* from, uptr size) {
659-
void* ctx;
660-
ASAN_INTERCEPTOR_ENTER(ctx, wcsncpy);
661-
AsanInitFromRtl();
662-
if (flags()->replace_str) {
663-
uptr from_size =
664-
Min(size, MaybeRealWcsnlen(from, size) + 1) * sizeof(wchar_t);
665-
CHECK_RANGES_OVERLAP("wcsncpy", to, from_size, from, from_size);
666-
ASAN_READ_RANGE(ctx, from, from_size);
667-
ASAN_WRITE_RANGE(ctx, to, size * sizeof(wchar_t));
668-
}
669-
return REAL(wcsncpy)(to, from, size);
670-
}
671-
672637
template <typename Fn>
673638
static ALWAYS_INLINE auto StrtolImpl(void *ctx, Fn real, const char *nptr,
674639
char **endptr, int base)
@@ -986,11 +951,6 @@ void InitializeAsanInterceptors() {
986951
ASAN_INTERCEPT_FUNC(strncat);
987952
ASAN_INTERCEPT_FUNC(strncpy);
988953
ASAN_INTERCEPT_FUNC(strdup);
989-
990-
// Intercept wcs* functions.
991-
ASAN_INTERCEPT_FUNC(wcscpy);
992-
ASAN_INTERCEPT_FUNC(wcsncpy);
993-
994954
# if ASAN_INTERCEPT___STRDUP
995955
ASAN_INTERCEPT_FUNC(__strdup);
996956
#endif

compiler-rt/lib/asan/asan_interceptors.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,6 @@ DECLARE_REAL(char*, strchr, const char *str, int c)
129129
DECLARE_REAL(SIZE_T, strlen, const char *s)
130130
DECLARE_REAL(char*, strncpy, char *to, const char *from, SIZE_T size)
131131
DECLARE_REAL(SIZE_T, strnlen, const char *s, SIZE_T maxlen)
132-
DECLARE_REAL(SIZE_T, wcsnlen, const wchar_t* s, SIZE_T maxlen)
133132
DECLARE_REAL(char*, strstr, const char *s1, const char *s2)
134133

135134
# if !SANITIZER_APPLE

compiler-rt/lib/asan/asan_win_static_runtime_thunk.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,6 @@ INTERCEPT_LIBRARY_FUNCTION_ASAN(strpbrk);
6363
INTERCEPT_LIBRARY_FUNCTION_ASAN(strspn);
6464
INTERCEPT_LIBRARY_FUNCTION_ASAN(strstr);
6565
INTERCEPT_LIBRARY_FUNCTION_ASAN(strtok);
66-
INTERCEPT_LIBRARY_FUNCTION_ASAN(wcscat);
67-
INTERCEPT_LIBRARY_FUNCTION_ASAN(wcscpy);
68-
INTERCEPT_LIBRARY_FUNCTION_ASAN(wcsncat);
69-
INTERCEPT_LIBRARY_FUNCTION_ASAN(wcsncpy);
7066
INTERCEPT_LIBRARY_FUNCTION_ASAN(wcslen);
7167
INTERCEPT_LIBRARY_FUNCTION_ASAN(wcsnlen);
7268

compiler-rt/lib/sanitizer_common/sanitizer_platform_interceptors.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,7 @@ SANITIZER_WEAK_IMPORT void *aligned_alloc(__sanitizer::usize __alignment,
551551
#define SANITIZER_INTERCEPT_MALLOC_USABLE_SIZE (!SI_MAC && !SI_NETBSD)
552552
#define SANITIZER_INTERCEPT_MCHECK_MPROBE SI_LINUX_NOT_ANDROID
553553
#define SANITIZER_INTERCEPT_WCSLEN 1
554-
#define SANITIZER_INTERCEPT_WCSCAT (SI_POSIX || SI_WINDOWS)
554+
#define SANITIZER_INTERCEPT_WCSCAT SI_POSIX
555555
#define SANITIZER_INTERCEPT_WCSDUP SI_POSIX
556556
#define SANITIZER_INTERCEPT_SIGNAL_AND_SIGACTION (!SI_WINDOWS && SI_NOT_FUCHSIA)
557557
#define SANITIZER_INTERCEPT_BSD_SIGNAL SI_ANDROID

compiler-rt/test/asan/TestCases/wcscat.cpp

Lines changed: 0 additions & 26 deletions
This file was deleted.

compiler-rt/test/asan/TestCases/wcscpy.cpp

Lines changed: 0 additions & 23 deletions
This file was deleted.

compiler-rt/test/asan/TestCases/wcsncat.cpp

Lines changed: 0 additions & 27 deletions
This file was deleted.

0 commit comments

Comments
 (0)