Skip to content

Commit 3a67d86

Browse files
authored
Merge branch 'main' into wcscat-implmentation
2 parents b38dd5e + c874185 commit 3a67d86

File tree

121 files changed

+3985
-3152
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

121 files changed

+3985
-3152
lines changed

clang/include/clang/Basic/DiagnosticSerializationKinds.td

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@ def err_fe_ast_file_modified : Error<
2424
DefaultFatal;
2525
def err_fe_pch_file_overridden : Error<
2626
"file '%0' from the precompiled header has been overridden">;
27-
def note_pch_required_by : Note<"'%0' required by '%1'">;
28-
def note_pch_rebuild_required : Note<"please rebuild precompiled header '%0'">;
27+
def note_ast_file_required_by : Note<"'%0' required by '%1'">;
28+
def note_ast_file_rebuild_required
29+
: Note<"please rebuild precompiled file '%0'">;
2930
def note_module_cache_path : Note<
3031
"after modifying system headers, please delete the module cache at '%0'">;
3132

clang/lib/Serialization/ASTReader.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2854,25 +2854,25 @@ InputFile ASTReader::getInputFile(ModuleFile &F, unsigned ID, bool Complain) {
28542854
while (!ImportStack.back()->ImportedBy.empty())
28552855
ImportStack.push_back(ImportStack.back()->ImportedBy[0]);
28562856

2857-
// The top-level PCH is stale.
2858-
StringRef TopLevelPCHName(ImportStack.back()->FileName);
2857+
// The top-level AST file is stale.
2858+
StringRef TopLevelASTFileName(ImportStack.back()->FileName);
28592859
Diag(diag::err_fe_ast_file_modified)
28602860
<< *Filename << moduleKindForDiagnostic(ImportStack.back()->Kind)
2861-
<< TopLevelPCHName << FileChange.Kind
2861+
<< TopLevelASTFileName << FileChange.Kind
28622862
<< (FileChange.Old && FileChange.New)
28632863
<< llvm::itostr(FileChange.Old.value_or(0))
28642864
<< llvm::itostr(FileChange.New.value_or(0));
28652865

28662866
// Print the import stack.
28672867
if (ImportStack.size() > 1) {
2868-
Diag(diag::note_pch_required_by)
2868+
Diag(diag::note_ast_file_required_by)
28692869
<< *Filename << ImportStack[0]->FileName;
28702870
for (unsigned I = 1; I < ImportStack.size(); ++I)
2871-
Diag(diag::note_pch_required_by)
2872-
<< ImportStack[I-1]->FileName << ImportStack[I]->FileName;
2871+
Diag(diag::note_ast_file_required_by)
2872+
<< ImportStack[I - 1]->FileName << ImportStack[I]->FileName;
28732873
}
28742874

2875-
Diag(diag::note_pch_rebuild_required) << TopLevelPCHName;
2875+
Diag(diag::note_ast_file_rebuild_required) << TopLevelASTFileName;
28762876
}
28772877

28782878
IsOutOfDate = true;

clang/test/Modules/module-file-modified.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@
88
#include "a.h"
99
int foo = 0; // redefinition of 'foo'
1010
// CHECK: fatal error: file {{.*}} has been modified since the module file {{.*}} was built
11+
// CHECK: note: please rebuild precompiled file
1112
// REQUIRES: shell

clang/test/Modules/validate-file-content.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,5 @@
2929
// CHECK: file '[[M_H:.*[/\\]m\.h]]' has been modified since the precompiled header '[[A_PCH:.*/a\.pch]]' was built: content changed
3030
// CHECK: '[[M_H]]' required by '[[M_PCM:.*[/\\]m.*\.pcm]]'
3131
// CHECK: '[[M_PCM]]' required by '[[A_PCH]]'
32-
// CHECK: please rebuild precompiled header '[[A_PCH]]'
32+
// CHECK: please rebuild precompiled file '[[A_PCH]]'
3333
// expected-no-diagnostics

clang/test/PCH/modified-module-dependency.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@
1717
// CHECK: file '[[TEST_H:.*[/\\]test\.h]]' has been modified since the precompiled header '[[PREFIX_PCH:.*/prefix\.pch]]' was built
1818
// CHECK: '[[TEST_H]]' required by '[[TEST_PCM:.*[/\\]test\.pcm]]'
1919
// CHECK: '[[TEST_PCM]]' required by '[[PREFIX_PCH]]'
20-
// CHECK: please rebuild precompiled header '[[PREFIX_PCH]]'
20+
// CHECK: please rebuild precompiled file '[[PREFIX_PCH]]'

clang/test/PCH/validate-file-content.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,5 @@
2525
// RUN: FileCheck %s < %t/stderr
2626
//
2727
// CHECK: file '[[M_H:.*[/\\]m\.h]]' has been modified since the precompiled header '[[A_PCH:.*/a\.pch]]' was built: content changed
28-
// CHECK: please rebuild precompiled header '[[A_PCH]]'
28+
// CHECK: please rebuild precompiled file '[[A_PCH]]'
2929
// expected-no-diagnostics

libc/config/linux/x86_64/entrypoints.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,7 @@ set(TARGET_LIBC_ENTRYPOINTS
366366
libc.src.wchar.wctob
367367
libc.src.wchar.wmemset
368368
libc.src.wchar.wcschr
369+
libc.src.wchar.wcsncmp
369370
libc.src.wchar.wcscmp
370371
libc.src.wchar.wcspbrk
371372
libc.src.wchar.wcsrchr
@@ -374,6 +375,7 @@ set(TARGET_LIBC_ENTRYPOINTS
374375
libc.src.wchar.wmempcpy
375376
libc.src.wchar.wmemcpy
376377
libc.src.wchar.wcscat
378+
libc.src.wchar.wcsstr
377379
libc.src.wchar.wcsncat
378380
libc.src.wchar.wcscpy
379381

libc/include/wchar.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,14 @@ functions:
4242
arguments:
4343
- type: const wchar_t *
4444
- type: wchar_t
45+
- name: wcsncmp
46+
standards:
47+
- stdc
48+
return_type: int
49+
arguments:
50+
- type: const wchar_t *
51+
- type: const wchar_t *
52+
- type: size_t
4553
- name: wcscmp
4654
standards:
4755
- stdc
@@ -101,6 +109,13 @@ functions:
101109
arguments:
102110
- type: __restrict wchar_t *
103111
- type: const __restrict wchar_t *
112+
- name: wcsstr
113+
standards:
114+
- stdc
115+
return_type: const wchar_t *
116+
arguments:
117+
- type: const wchar_t *
118+
- type: const wchar_t *
104119
- name: wcsncat
105120
standards:
106121
- stdc

libc/src/wchar/CMakeLists.txt

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,17 @@ add_entrypoint_object(
8989
libc.hdr.wchar_macros
9090
)
9191

92+
add_entrypoint_object(
93+
wcsncmp
94+
SRCS
95+
wcsncmp.cpp
96+
HDRS
97+
wcsncmp.h
98+
DEPENDS
99+
libc.hdr.wchar_macros
100+
libc.hdr.types.size_t
101+
)
102+
92103
add_entrypoint_object(
93104
wcsspn
94105
SRCS
@@ -132,7 +143,19 @@ add_entrypoint_object(
132143
wcscat.cpp
133144
HDRS
134145
wcscat.h
135-
DEPEMDS
146+
DEPENDS
147+
libc.hdr.types.size_t
148+
libc.hdr.wchar_macros
149+
libc.src.string.string_utils
150+
)
151+
152+
add_entrypoint_object(
153+
wcsstr
154+
SRCS
155+
wcsstr.cpp
156+
HDRS
157+
wcsstr.h
158+
DEPENDS
136159
libc.hdr.types.size_t
137160
libc.hdr.wchar_macros
138161
libc.src.string.string_utils

libc/src/wchar/wcsncmp.cpp

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
//===-- Implementation of wcsncmp -----------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#include "src/wchar/wcsncmp.h"
10+
11+
#include "hdr/types/size_t.h"
12+
#include "hdr/types/wchar_t.h"
13+
#include "src/__support/common.h"
14+
#include "src/__support/macros/null_check.h"
15+
16+
namespace LIBC_NAMESPACE_DECL {
17+
18+
LLVM_LIBC_FUNCTION(int, wcsncmp,
19+
(const wchar_t *left, const wchar_t *right, size_t n)) {
20+
LIBC_CRASH_ON_NULLPTR(left);
21+
LIBC_CRASH_ON_NULLPTR(right);
22+
23+
if (n == 0)
24+
return 0;
25+
26+
auto comp = [](wchar_t l, wchar_t r) -> int { return l - r; };
27+
28+
for (; n > 1; --n, ++left, ++right) {
29+
wchar_t lc = *left;
30+
if (!comp(lc, '\0') || comp(lc, *right))
31+
break;
32+
}
33+
return comp(*reinterpret_cast<const wchar_t *>(left),
34+
*reinterpret_cast<const wchar_t *>(right));
35+
}
36+
37+
} // namespace LIBC_NAMESPACE_DECL

0 commit comments

Comments
 (0)