Skip to content

Commit 2c1b70b

Browse files
authored
Merge branch 'main' into fix-release-cache
2 parents ca503d0 + 0ef7b1d commit 2c1b70b

File tree

361 files changed

+3500
-2034
lines changed

Some content is hidden

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

361 files changed

+3500
-2034
lines changed

bolt/lib/Profile/YAMLProfileReader.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,7 @@ Error YAMLProfileReader::preprocessProfile(BinaryContext &BC) {
373373
return errorCodeToError(EC);
374374
}
375375
yaml::Input YamlInput(MB.get()->getBuffer());
376+
YamlInput.setAllowUnknownKeys(true);
376377

377378
// Consume YAML file.
378379
YamlInput >> YamlBP;

bolt/test/X86/yaml-unknown-keys.test

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
## Test that BOLT gracefully handles a YAML profile with unknown keys.
2+
3+
# REQUIRES: system-linux
4+
# RUN: split-file %s %t
5+
# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown %t/main.s -o %t.o
6+
# RUN: %clang %cflags %t.o -o %t.exe -Wl,-q -nostdlib
7+
# RUN: llvm-bolt %t.exe -o %t.null --data %t/profile.yaml \
8+
# RUN: --profile-ignore-hash -v=1 2>&1 | FileCheck %s
9+
# CHECK: warning: unknown key 'unknown-header-key'
10+
# CHECK: warning: unknown key 'unknown_succ_key'
11+
# CHECK: warning: unknown key 'unknown_block_key'
12+
# CHECK: warning: unknown key 'unknown_function_key'
13+
# CHECK: warning: unknown key 'unknown_toplev_key'
14+
#--- main.s
15+
.globl main
16+
.type main, %function
17+
main:
18+
.cfi_startproc
19+
cmpl $0x0, %eax
20+
jne .LBB0
21+
.LBB0:
22+
retq
23+
.cfi_endproc
24+
.size main, .-main
25+
#--- profile.yaml
26+
---
27+
header:
28+
profile-version: 1
29+
binary-name: 'yaml-multiple-profiles.test.tmp.exe'
30+
binary-build-id: '<unknown>'
31+
profile-flags: [ lbr ]
32+
profile-origin: branch profile reader
33+
profile-events: ''
34+
dfs-order: false
35+
unknown-header-key: true
36+
functions:
37+
- name: 'main'
38+
fid: 1
39+
hash: 0x50BBA3441D436491
40+
exec: 1
41+
nblocks: 1
42+
blocks:
43+
- bid: 0
44+
insns: 2
45+
hash: 0x4D4D8FAF7D4C0000
46+
succ: [ { bid: 1, cnt: 0, unknown_succ_key: 0x10 } ]
47+
unknown_block_key: [ ]
48+
unknown_function_key: 1
49+
unknown_toplev_key: ''
50+
...

bolt/tools/merge-fdata/merge-fdata.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,7 @@ int main(int argc, char **argv) {
392392
if (std::error_code EC = MB.getError())
393393
report_error(InputDataFilename, EC);
394394
yaml::Input YamlInput(MB.get()->getBuffer());
395+
YamlInput.setAllowUnknownKeys(true);
395396

396397
errs() << "Merging data from " << InputDataFilename << "...\n";
397398

clang/cmake/caches/Fuchsia-stage2.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ foreach(target aarch64-unknown-linux-gnu;armv7-unknown-linux-gnueabihf;i386-unkn
155155
set(BUILTINS_${target}_CMAKE_MODULE_LINKER_FLAGS "-fuse-ld=lld" CACHE STRING "")
156156
set(BUILTINS_${target}_CMAKE_EXE_LINKER_FLAG "-fuse-ld=lld" CACHE STRING "")
157157
set(BUILTINS_${target}_COMPILER_RT_BUILD_STANDALONE_LIBATOMIC ON CACHE BOOL "")
158+
set(BUILTINS_${target}_COMPILER_RT_LIBATOMIC_USE_PTHREAD ON CACHE BOOL "")
158159

159160
# Set the per-target runtimes options.
160161
list(APPEND RUNTIME_TARGETS "${target}")
@@ -169,6 +170,7 @@ foreach(target aarch64-unknown-linux-gnu;armv7-unknown-linux-gnueabihf;i386-unkn
169170
set(RUNTIMES_${target}_CMAKE_EXE_LINKER_FLAGS "-fuse-ld=lld" CACHE STRING "")
170171
set(RUNTIMES_${target}_COMPILER_RT_CXX_LIBRARY "libcxx" CACHE STRING "")
171172
set(RUNTIMES_${target}_COMPILER_RT_USE_BUILTINS_LIBRARY ON CACHE BOOL "")
173+
set(RUNTIMES_${target}_COMPILER_RT_USE_ATOMIC_LIBRARY ON CACHE BOOL "")
172174
set(RUNTIMES_${target}_COMPILER_RT_USE_LLVM_UNWINDER ON CACHE BOOL "")
173175
set(RUNTIMES_${target}_COMPILER_RT_CAN_EXECUTE_TESTS ON CACHE BOOL "")
174176
set(RUNTIMES_${target}_COMPILER_RT_BUILD_STANDALONE_LIBATOMIC ON CACHE BOOL "")

clang/docs/ReleaseNotes.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,7 @@ Bug Fixes to C++ Support
341341
- Template parameter names are considered in the name lookup of out-of-line class template
342342
specialization right before its declaration context. (#GH64082)
343343
- Fixed a constraint comparison bug for friend declarations. (#GH78101)
344+
- Fix handling of ``_`` as the name of a lambda's init capture variable. (#GH107024)
344345

345346
Bug Fixes to AST Handling
346347
^^^^^^^^^^^^^^^^^^^^^^^^^

clang/docs/analyzer/checkers.rst

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1293,6 +1293,22 @@ security.insecureAPI.DeprecatedOrUnsafeBufferHandling (C)
12931293
strncpy(buf, "a", 1); // warn
12941294
}
12951295
1296+
.. _security-MmapWriteExec:
1297+
1298+
security.MmapWriteExec (C)
1299+
""""""""""""""""""""""""""
1300+
Warn on ``mmap()`` calls with both writable and executable access.
1301+
1302+
.. code-block:: c
1303+
1304+
void test(int n) {
1305+
void *c = mmap(NULL, 32, PROT_READ | PROT_WRITE | PROT_EXEC,
1306+
MAP_PRIVATE | MAP_ANON, -1, 0);
1307+
// warn: Both PROT_WRITE and PROT_EXEC flags are set. This can lead to
1308+
// exploitable memory regions, which could be overwritten with malicious
1309+
// code
1310+
}
1311+
12961312
.. _security-putenv-stack-array:
12971313
12981314
security.PutenvStackArray (C)
@@ -2967,22 +2983,6 @@ Warn about buffer overflows (newer checker).
29672983
char c = s[x]; // warn: index is tainted
29682984
}
29692985
2970-
.. _alpha-security-MmapWriteExec:
2971-
2972-
alpha.security.MmapWriteExec (C)
2973-
""""""""""""""""""""""""""""""""
2974-
Warn on mmap() calls that are both writable and executable.
2975-
2976-
.. code-block:: c
2977-
2978-
void test(int n) {
2979-
void *c = mmap(NULL, 32, PROT_READ | PROT_WRITE | PROT_EXEC,
2980-
MAP_PRIVATE | MAP_ANON, -1, 0);
2981-
// warn: Both PROT_WRITE and PROT_EXEC flags are set. This can lead to
2982-
// exploitable memory regions, which could be overwritten with malicious
2983-
// code
2984-
}
2985-
29862986
.. _alpha-security-ReturnPtrRange:
29872987
29882988
alpha.security.ReturnPtrRange (C)

clang/include/clang/Basic/Attr.td

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1073,6 +1073,36 @@ static llvm::StringRef canonicalizePlatformName(llvm::StringRef Platform) {
10731073
.Case("ShaderModel", "shadermodel")
10741074
.Default(Platform);
10751075
}
1076+
static std::vector<llvm::StringRef> equivalentPlatformNames(llvm::StringRef Platform) {
1077+
return llvm::StringSwitch<std::vector<llvm::StringRef>>(Platform)
1078+
.Case("ios", {"ios", "iOS"})
1079+
.Case("iOS", {"ios", "iOS"})
1080+
.Case("macos", {"macos", "macOS"})
1081+
.Case("macOS", {"macos", "macOS"})
1082+
.Case("tvos", {"tvos", "tvOS"})
1083+
.Case("tvOS", {"tvos", "tvOS"})
1084+
.Case("watchos", {"watchos", "watchOS"})
1085+
.Case("watchOS", {"watchos", "watchOS"})
1086+
.Case("ios_app_extension", {"iOSApplicationExtension", "ios_app_extension"})
1087+
.Case("iOSApplicationExtension", {"iOSApplicationExtension", "ios_app_extension"})
1088+
.Case("macos_app_extension", {"macOSApplicationExtension", "macos_app_extension"})
1089+
.Case("macOSApplicationExtension", {"macOSApplicationExtension", "macos_app_extension"})
1090+
.Case("tvos_app_extension", {"tvOSApplicationExtension", "tvos_app_extension"})
1091+
.Case("tvOSApplicationExtension", {"tvOSApplicationExtension", "tvos_app_extension"})
1092+
.Case("watchos_app_extension", {"watchOSApplicationExtension", "watchos_app_extension"})
1093+
.Case("watchOSApplicationExtension", {"watchOSApplicationExtension", "watchos_app_extension"})
1094+
.Case("maccatalyst", {"macCatalyst", "maccatalyst"})
1095+
.Case("macCatalyst", {"macCatalyst", "maccatalyst"})
1096+
.Case("maccatalyst_app_extension", {"macCatalystApplicationExtension", "maccatalyst_app_extension"})
1097+
.Case("macCatalystApplicationExtension", {"macCatalystApplicationExtension", "maccatalyst_app_extension"})
1098+
.Case("xros", {"visionos", "visionOS", "xros"})
1099+
.Case("visionOS", {"visionos", "visionOS", "xros"})
1100+
.Case("visionos", {"visionos", "visionOS", "xros"})
1101+
.Case("xros_app_extension", {"visionOSApplicationExtension", "visionos_app_extension", "xros_app_extension"})
1102+
.Case("visionOSApplicationExtension", {"visionOSApplicationExtension", "visionos_app_extension", "xros_app_extension"})
1103+
.Case("visionos_app_extension", {"visionOSApplicationExtension", "visionos_app_extension", "xros_app_extension"})
1104+
.Default({Platform});
1105+
}
10761106
static llvm::Triple::EnvironmentType getEnvironmentType(llvm::StringRef Environment) {
10771107
return llvm::StringSwitch<llvm::Triple::EnvironmentType>(Environment)
10781108
.Case("pixel", llvm::Triple::Pixel)

clang/include/clang/StaticAnalyzer/Checkers/Checkers.td

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1000,6 +1000,10 @@ def FloatLoopCounter : Checker<"FloatLoopCounter">,
10001000
Dependencies<[SecuritySyntaxChecker]>,
10011001
Documentation<HasDocumentation>;
10021002

1003+
def MmapWriteExecChecker : Checker<"MmapWriteExec">,
1004+
HelpText<"Warn on mmap() calls with both writable and executable access">,
1005+
Documentation<HasDocumentation>;
1006+
10031007
def PutenvStackArray : Checker<"PutenvStackArray">,
10041008
HelpText<"Finds calls to the function 'putenv' which pass a pointer to "
10051009
"an automatic (stack-allocated) array as the argument.">,
@@ -1039,10 +1043,6 @@ def ArrayBoundCheckerV2 : Checker<"ArrayBoundV2">,
10391043
HelpText<"Warn about buffer overflows (newer checker)">,
10401044
Documentation<HasDocumentation>;
10411045

1042-
def MmapWriteExecChecker : Checker<"MmapWriteExec">,
1043-
HelpText<"Warn on mmap() calls that are both writable and executable">,
1044-
Documentation<HasDocumentation>;
1045-
10461046
def ReturnPointerRangeChecker : Checker<"ReturnPtrRange">,
10471047
HelpText<"Check for an out-of-bound pointer being returned to callers">,
10481048
Documentation<HasDocumentation>;

0 commit comments

Comments
 (0)