Skip to content

Commit 34ec1c1

Browse files
authored
Merge branch 'release/20.x' into issue130158
2 parents 9cb7ed3 + 5ba1949 commit 34ec1c1

File tree

6 files changed

+55
-13
lines changed

6 files changed

+55
-13
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -545,6 +545,11 @@ New Compiler Flags
545545
- The ``-Warray-compare-cxx26`` warning has been added to warn about array comparison
546546
starting from C++26, this warning is enabled as an error by default.
547547

548+
- The ``-Wnontrivial-memcall`` warning has been added to warn about
549+
passing non-trivially-copyable destination parameter to ``memcpy``,
550+
``memset`` and similar functions for which it is a documented undefined
551+
behavior. It is implied by ``-Wnontrivial-memaccess``
552+
548553
- clang-cl and clang-dxc now support ``-fdiagnostics-color=[auto|never|always]``
549554
in addition to ``-f[no-]color-diagnostics``.
550555

@@ -576,11 +581,6 @@ Modified Compiler Flags
576581
to utilize these vector libraries. The behavior for all other vector function
577582
libraries remains unchanged.
578583

579-
- The ``-Wnontrivial-memcall`` warning has been added to warn about
580-
passing non-trivially-copyable destination parameter to ``memcpy``,
581-
``memset`` and similar functions for which it is a documented undefined
582-
behavior. It is implied by ``-Wnontrivial-memaccess``
583-
584584
- Added ``-fmodules-reduced-bmi`` flag corresponding to
585585
``-fexperimental-modules-reduced-bmi`` flag. The ``-fmodules-reduced-bmi`` flag
586586
is intended to be enabled by default in the future.

clang/lib/Format/Format.cpp

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2114,10 +2114,14 @@ std::error_code parseConfiguration(llvm::MemoryBufferRef Config,
21142114
FormatStyle::FormatStyleSet StyleSet;
21152115
bool LanguageFound = false;
21162116
for (const FormatStyle &Style : llvm::reverse(Styles)) {
2117-
if (Style.Language != FormatStyle::LK_None)
2117+
const auto Lang = Style.Language;
2118+
if (Lang != FormatStyle::LK_None)
21182119
StyleSet.Add(Style);
2119-
if (Style.Language == Language)
2120+
if (Lang == Language ||
2121+
// For backward compatibility.
2122+
(Lang == FormatStyle::LK_Cpp && Language == FormatStyle::LK_C)) {
21202123
LanguageFound = true;
2124+
}
21212125
}
21222126
if (!LanguageFound) {
21232127
if (Styles.empty() || Styles[0].Language != FormatStyle::LK_None)
@@ -2157,8 +2161,14 @@ FormatStyle::FormatStyleSet::Get(FormatStyle::LanguageKind Language) const {
21572161
if (!Styles)
21582162
return std::nullopt;
21592163
auto It = Styles->find(Language);
2160-
if (It == Styles->end())
2161-
return std::nullopt;
2164+
if (It == Styles->end()) {
2165+
if (Language != FormatStyle::LK_C)
2166+
return std::nullopt;
2167+
// For backward compatibility.
2168+
It = Styles->find(FormatStyle::LK_Cpp);
2169+
if (It == Styles->end())
2170+
return std::nullopt;
2171+
}
21622172
FormatStyle Style = It->second;
21632173
Style.StyleSet = *this;
21642174
return Style;

clang/unittests/Format/ConfigParseTest.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1214,6 +1214,26 @@ TEST(ConfigParseTest, ParsesConfigurationWithLanguages) {
12141214
IndentWidth, 56u);
12151215
}
12161216

1217+
TEST(ConfigParseTest, AllowCppForC) {
1218+
FormatStyle Style = {};
1219+
Style.Language = FormatStyle::LK_C;
1220+
EXPECT_EQ(parseConfiguration("Language: Cpp", &Style), ParseError::Success);
1221+
1222+
CHECK_PARSE("---\n"
1223+
"IndentWidth: 4\n"
1224+
"---\n"
1225+
"Language: Cpp\n"
1226+
"IndentWidth: 8\n",
1227+
IndentWidth, 8u);
1228+
1229+
EXPECT_EQ(parseConfiguration("---\n"
1230+
"Language: ObjC\n"
1231+
"---\n"
1232+
"Language: Cpp\n",
1233+
&Style),
1234+
ParseError::Success);
1235+
}
1236+
12171237
TEST(ConfigParseTest, UsesLanguageForBasedOnStyle) {
12181238
FormatStyle Style = {};
12191239
Style.Language = FormatStyle::LK_JavaScript;

libcxx/test/tools/clang_tidy_checks/CMakeLists.txt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ set(Clang_DIR_SAVE ${Clang_DIR})
88
# versions must match. Otherwise there likely will be ODR-violations. This had
99
# led to crashes and incorrect output of the clang-tidy based checks.
1010
find_package(Clang ${CMAKE_CXX_COMPILER_VERSION})
11+
12+
set(LLVM_DIR "${LLVM_DIR_SAVE}" CACHE PATH "The directory containing a CMake configuration file for LLVM." FORCE)
13+
set(Clang_DIR "${Clang_DIR_SAVE}" CACHE PATH "The directory containing a CMake configuration file for Clang." FORCE)
14+
1115
if(NOT Clang_FOUND)
1216
message(STATUS "Clang-tidy tests are disabled since the "
1317
"Clang development package is unavailable.")
@@ -19,9 +23,6 @@ if(NOT TARGET clangTidy)
1923
return()
2024
endif()
2125

22-
set(LLVM_DIR "${LLVM_DIR_SAVE}" CACHE PATH "The directory containing a CMake configuration file for LLVM." FORCE)
23-
set(Clang_DIR "${Clang_DIR_SAVE}" CACHE PATH "The directory containing a CMake configuration file for Clang." FORCE)
24-
2526
message(STATUS "Found system-installed LLVM ${LLVM_PACKAGE_VERSION} with headers in ${LLVM_INCLUDE_DIRS}")
2627

2728
set(CMAKE_CXX_STANDARD 20)

llvm/lib/MC/MCWinCOFFStreamer.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,8 @@ void MCWinCOFFStreamer::emitCOFFSafeSEH(MCSymbol const *Symbol) {
299299
return;
300300

301301
MCSection *SXData = getContext().getObjectFileInfo()->getSXDataSection();
302-
changeSection(SXData);
302+
pushSection();
303+
switchSection(SXData);
303304
SXData->ensureMinAlignment(Align(4));
304305

305306
insert(getContext().allocFragment<MCSymbolIdFragment>(Symbol));
@@ -310,6 +311,7 @@ void MCWinCOFFStreamer::emitCOFFSafeSEH(MCSymbol const *Symbol) {
310311
// function. Go ahead and oblige it here.
311312
CSymbol->setType(COFF::IMAGE_SYM_DTYPE_FUNCTION
312313
<< COFF::SCT_COMPLEX_TYPE_SHIFT);
314+
popSection();
313315
}
314316

315317
void MCWinCOFFStreamer::emitCOFFSymbolIndex(MCSymbol const *Symbol) {

llvm/test/CodeGen/X86/win32-eh.ll

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
; RUN: llc -mtriple=i686-pc-windows-msvc < %s | FileCheck %s
2+
; RUN: llc -mtriple=i686-pc-windows-msvc -filetype=obj < %s -o %t
23

34
declare void @may_throw_or_crash()
45
declare i32 @_except_handler3(...)
@@ -208,6 +209,14 @@ catch:
208209
; CHECK-NEXT: .long 0
209210
; CHECK-NEXT: .long 1
210211

212+
; CHECK-LABEL: inlineasm:
213+
; CHECK: .safeseh my_handler
214+
define i32 @inlineasm() {
215+
entry:
216+
call void asm sideeffect ".safeseh my_handler", "~{dirflag},~{fpsr},~{flags}"()
217+
ret i32 0
218+
}
219+
211220
; CHECK-LABEL: ___ehhandler$use_CxxFrameHandler3:
212221
; CHECK: movl $L__ehtable$use_CxxFrameHandler3, %eax
213222
; CHECK-NEXT: jmp ___CxxFrameHandler3 # TAILCALL

0 commit comments

Comments
 (0)