Skip to content

Commit 842753f

Browse files
authored
Merge branch 'release/20.x' into cherry-pick-release-20x-wasmsym
2 parents f9f7225 + a7166c3 commit 842753f

File tree

40 files changed

+447
-106
lines changed

40 files changed

+447
-106
lines changed

clang-tools-extra/clang-tidy/tool/run-clang-tidy.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ def find_compilation_database(path: str) -> str:
8787

8888

8989
def get_tidy_invocation(
90-
f: str,
90+
f: Optional[str],
9191
clang_tidy_binary: str,
9292
checks: str,
9393
tmpdir: Optional[str],
@@ -147,7 +147,8 @@ def get_tidy_invocation(
147147
start.append(f"--warnings-as-errors={warnings_as_errors}")
148148
if allow_no_checks:
149149
start.append("--allow-no-checks")
150-
start.append(f)
150+
if f:
151+
start.append(f)
151152
return start
152153

153154

@@ -490,7 +491,7 @@ async def main() -> None:
490491

491492
try:
492493
invocation = get_tidy_invocation(
493-
"",
494+
None,
494495
clang_tidy_binary,
495496
args.checks,
496497
None,

clang-tools-extra/docs/ReleaseNotes.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,9 @@ Improvements to clang-tidy
190190
- Fixed bug in :program:`clang-tidy` by which `HeaderFilterRegex` did not take
191191
effect when passed via the `.clang-tidy` file.
192192

193+
- Fixed bug in :program:`run_clang_tidy.py` where the program would not
194+
correctly display the checks enabled by the top-level `.clang-tidy` file.
195+
193196
New checks
194197
^^^^^^^^^^
195198

clang/include/clang/Driver/Distro.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ class Distro {
3939
DebianBullseye,
4040
DebianBookworm,
4141
DebianTrixie,
42+
DebianForky,
43+
DebianDuke,
4244
Exherbo,
4345
RHEL5,
4446
RHEL6,
@@ -128,7 +130,7 @@ class Distro {
128130
bool IsOpenSUSE() const { return DistroVal == OpenSUSE; }
129131

130132
bool IsDebian() const {
131-
return DistroVal >= DebianLenny && DistroVal <= DebianTrixie;
133+
return DistroVal >= DebianLenny && DistroVal <= DebianDuke;
132134
}
133135

134136
bool IsUbuntu() const {

clang/include/clang/Interpreter/Interpreter.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,9 @@ class Interpreter {
116116
/// Compiler instance performing the incremental compilation.
117117
std::unique_ptr<CompilerInstance> CI;
118118

119+
/// An optional compiler instance for CUDA offloading
120+
std::unique_ptr<CompilerInstance> DeviceCI;
121+
119122
protected:
120123
// Derived classes can use an extended interface of the Interpreter.
121124
Interpreter(std::unique_ptr<CompilerInstance> Instance, llvm::Error &Err,

clang/lib/Driver/Distro.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,10 @@ static Distro::DistroType DetectDistro(llvm::vfs::FileSystem &VFS) {
160160
return Distro::DebianBookworm;
161161
case 13:
162162
return Distro::DebianTrixie;
163+
case 14:
164+
return Distro::DebianForky;
165+
case 15:
166+
return Distro::DebianDuke;
163167
default:
164168
return Distro::UnknownDistro;
165169
}
@@ -173,6 +177,8 @@ static Distro::DistroType DetectDistro(llvm::vfs::FileSystem &VFS) {
173177
.Case("bullseye/sid", Distro::DebianBullseye)
174178
.Case("bookworm/sid", Distro::DebianBookworm)
175179
.Case("trixie/sid", Distro::DebianTrixie)
180+
.Case("forky/sid", Distro::DebianForky)
181+
.Case("duke/sid", Distro::DebianDuke)
176182
.Default(Distro::UnknownDistro);
177183
}
178184

clang/lib/Format/UnwrappedLineParser.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2581,7 +2581,8 @@ bool UnwrappedLineParser::parseParens(TokenType AmpAmpTokenType) {
25812581
if (Prev) {
25822582
auto OptionalParens = [&] {
25832583
if (MightBeStmtExpr || MightBeFoldExpr || Line->InMacroBody ||
2584-
SeenComma || Style.RemoveParentheses == FormatStyle::RPS_Leave) {
2584+
SeenComma || Style.RemoveParentheses == FormatStyle::RPS_Leave ||
2585+
RParen->getPreviousNonComment() == LParen) {
25852586
return false;
25862587
}
25872588
const bool DoubleParens =

clang/lib/Interpreter/DeviceOffload.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,12 @@
2525
namespace clang {
2626

2727
IncrementalCUDADeviceParser::IncrementalCUDADeviceParser(
28-
std::unique_ptr<CompilerInstance> DeviceInstance,
29-
CompilerInstance &HostInstance,
28+
CompilerInstance &DeviceInstance, CompilerInstance &HostInstance,
3029
llvm::IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem> FS,
3130
llvm::Error &Err, const std::list<PartialTranslationUnit> &PTUs)
32-
: IncrementalParser(*DeviceInstance, Err), PTUs(PTUs), VFS(FS),
31+
: IncrementalParser(DeviceInstance, Err), PTUs(PTUs), VFS(FS),
3332
CodeGenOpts(HostInstance.getCodeGenOpts()),
34-
TargetOpts(DeviceInstance->getTargetOpts()) {
33+
TargetOpts(DeviceInstance.getTargetOpts()) {
3534
if (Err)
3635
return;
3736
StringRef Arch = TargetOpts.CPU;
@@ -41,7 +40,6 @@ IncrementalCUDADeviceParser::IncrementalCUDADeviceParser(
4140
llvm::inconvertibleErrorCode()));
4241
return;
4342
}
44-
DeviceCI = std::move(DeviceInstance);
4543
}
4644

4745
llvm::Expected<llvm::StringRef> IncrementalCUDADeviceParser::GeneratePTX() {

clang/lib/Interpreter/DeviceOffload.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@ class IncrementalCUDADeviceParser : public IncrementalParser {
2828

2929
public:
3030
IncrementalCUDADeviceParser(
31-
std::unique_ptr<CompilerInstance> DeviceInstance,
32-
CompilerInstance &HostInstance,
31+
CompilerInstance &DeviceInstance, CompilerInstance &HostInstance,
3332
llvm::IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem> VFS,
3433
llvm::Error &Err, const std::list<PartialTranslationUnit> &PTUs);
3534

@@ -42,7 +41,6 @@ class IncrementalCUDADeviceParser : public IncrementalParser {
4241
~IncrementalCUDADeviceParser();
4342

4443
protected:
45-
std::unique_ptr<CompilerInstance> DeviceCI;
4644
int SMVersion;
4745
llvm::SmallString<1024> PTXCode;
4846
llvm::SmallVector<char, 1024> FatbinContent;

clang/lib/Interpreter/Interpreter.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,10 @@ Interpreter::Interpreter(std::unique_ptr<CompilerInstance> Instance,
416416
Interpreter::~Interpreter() {
417417
IncrParser.reset();
418418
Act->FinalizeAction();
419+
if (DeviceParser)
420+
DeviceParser.reset();
421+
if (DeviceAct)
422+
DeviceAct->FinalizeAction();
419423
if (IncrExecutor) {
420424
if (llvm::Error Err = IncrExecutor->cleanUp())
421425
llvm::report_fatal_error(
@@ -501,8 +505,11 @@ Interpreter::createWithCUDA(std::unique_ptr<CompilerInstance> CI,
501505

502506
DCI->ExecuteAction(*Interp->DeviceAct);
503507

508+
Interp->DeviceCI = std::move(DCI);
509+
504510
auto DeviceParser = std::make_unique<IncrementalCUDADeviceParser>(
505-
std::move(DCI), *Interp->getCompilerInstance(), IMVFS, Err, Interp->PTUs);
511+
*Interp->DeviceCI, *Interp->getCompilerInstance(), IMVFS, Err,
512+
Interp->PTUs);
506513

507514
if (Err)
508515
return std::move(Err);

clang/lib/Parse/ParseExpr.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2237,8 +2237,6 @@ Parser::ParsePostfixExpressionSuffix(ExprResult LHS) {
22372237
if (PP.isCodeCompletionReached() && !CalledSignatureHelp)
22382238
RunSignatureHelp();
22392239
LHS = ExprError();
2240-
} else if (!HasError && HasTrailingComma) {
2241-
Diag(Tok, diag::err_expected_expression);
22422240
} else if (LHS.isInvalid()) {
22432241
for (auto &E : ArgExprs)
22442242
Actions.CorrectDelayedTyposInExpr(E);
@@ -3738,7 +3736,6 @@ bool Parser::ParseExpressionList(SmallVectorImpl<Expr *> &Exprs,
37383736
if (Tok.is(tok::r_paren)) {
37393737
if (HasTrailingComma)
37403738
*HasTrailingComma = true;
3741-
break;
37423739
}
37433740
}
37443741
if (SawError) {

clang/test/Parser/recovery.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,3 +222,21 @@ void k() {
222222
func(1, ); // expected-error {{expected expression}}
223223
}
224224
}
225+
226+
namespace GH136254 {
227+
228+
void call() {
229+
[a(42, )]() {} (); // expected-error {{expected expression}}
230+
231+
int *b = new int(42, ); // expected-error {{expected expression}}
232+
233+
struct S {
234+
int c;
235+
236+
S() : c(42, ) {} // expected-error {{expected expression}}
237+
};
238+
239+
int d(42, ); // expected-error {{expected expression}}
240+
}
241+
242+
}

clang/unittests/Format/FormatTest.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27895,6 +27895,8 @@ TEST_F(FormatTest, RemoveParentheses) {
2789527895
verifyFormat("return ((... && std::is_convertible_v<TArgsLocal, TArgs>));",
2789627896
"return (((... && std::is_convertible_v<TArgsLocal, TArgs>)));",
2789727897
Style);
27898+
verifyFormat("MOCK_METHOD(void, Function, (), override);",
27899+
"MOCK_METHOD(void, Function, (), (override));", Style);
2789827900

2789927901
Style.RemoveParentheses = FormatStyle::RPS_ReturnStatement;
2790027902
verifyFormat("#define Return0 return (0);", Style);

flang/lib/Semantics/check-declarations.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,10 @@ void CheckHelper::Check(const Symbol &symbol) {
359359
// are not pertinent to the characteristics of the procedure.
360360
// Restrictions on entities in pure procedure interfaces don't need
361361
// enforcement.
362-
} else if (!FindCommonBlockContaining(symbol) && IsSaved(symbol)) {
362+
} else if (symbol.has<AssocEntityDetails>() ||
363+
FindCommonBlockContaining(symbol)) {
364+
// can look like they have SAVE but are fine in PURE
365+
} else if (IsSaved(symbol)) {
363366
if (IsInitialized(symbol)) {
364367
messages_.Say(
365368
"A pure subprogram may not initialize a variable"_err_en_US);

flang/test/Semantics/call10.f90

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ pure subroutine s05a
3636
end subroutine
3737
end interface
3838

39+
real :: moduleVar = 1.
40+
3941
contains
4042

4143
subroutine impure(x)
@@ -117,6 +119,8 @@ pure subroutine s05 ! C1589
117119
!ERROR: A pure subprogram may not initialize a variable
118120
real :: v6 = 0.
119121
end block
122+
associate (x => moduleVar) ! ok
123+
end associate
120124
end subroutine
121125
pure subroutine s06 ! C1589
122126
!ERROR: A pure subprogram may not have a variable with the VOLATILE attribute

libcxx/docs/ReleaseNotes/20.rst

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,6 @@ Deprecations and Removals
153153
headers as an extension and only deprecates them. The ``_LIBCPP_DISABLE_DEPRECATION_WARNINGS`` macro can be defined to
154154
suppress deprecation for these headers.
155155

156-
- The ``_LIBCPP_DISABLE_AVAILABILITY`` macro that was used to force-disable availability markup has now been removed.
157-
Whether availability markup is used by the library is now solely controlled at configuration-time.
158-
159156
- The pointer safety functions ``declare_reachable``, ``declare_no_pointers``, ``undeclare_no_pointers`` and
160157
``__undeclare_reachable`` have been removed from the library. These functions were never implemented in a non-trivial
161158
way, making it very unlikely that any binary depends on them.

libcxx/include/__configuration/availability.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,13 @@
6969

7070
// Availability markup is disabled when building the library, or when a non-Clang
7171
// compiler is used because only Clang supports the necessary attributes.
72-
#if defined(_LIBCPP_BUILDING_LIBRARY) || defined(_LIBCXXABI_BUILDING_LIBRARY) || !defined(_LIBCPP_COMPILER_CLANG_BASED)
72+
//
73+
// We also allow users to force-disable availability markup via the `_LIBCPP_DISABLE_AVAILABILITY`
74+
// macro because that is the only way to work around a Clang bug related to availability
75+
// attributes: https://github.com/llvm/llvm-project/issues/134151.
76+
// Once that bug has been fixed, we should remove the macro.
77+
#if defined(_LIBCPP_BUILDING_LIBRARY) || defined(_LIBCXXABI_BUILDING_LIBRARY) || \
78+
!defined(_LIBCPP_COMPILER_CLANG_BASED) || defined(_LIBCPP_DISABLE_AVAILABILITY)
7379
# undef _LIBCPP_HAS_VENDOR_AVAILABILITY_ANNOTATIONS
7480
# define _LIBCPP_HAS_VENDOR_AVAILABILITY_ANNOTATIONS 0
7581
#endif
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
//===----------------------------------------------------------------------===//
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+
// REQUIRES: stdlib=apple-libc++
10+
11+
// This test is dependent on the code generated by the compiler, and it doesn't
12+
// work properly with older AppleClangs.
13+
// UNSUPPORTED: apple-clang-15
14+
15+
// This test ensures that we retain a way to disable availability markup on Apple platforms
16+
// in order to work around Clang bug https://github.com/llvm/llvm-project/issues/134151.
17+
//
18+
// Once that bug has been fixed or once we've made changes to libc++'s use of availability
19+
// that render that workaround unnecessary, the macro and this test can be removed.
20+
//
21+
// The test works by creating a final linked image that refers to a function marked with
22+
// both an availability attribute and with _LIBCPP_HIDE_FROM_ABI. We then check that this
23+
// generates a weak reference to the function -- without the bug, we'd expect a strong
24+
// reference or no reference at all instead.
25+
26+
// First, test the test. Make sure that we do (incorrectly) produce a weak definition when we
27+
// don't define _LIBCPP_DISABLE_AVAILABILITY. Otherwise, something may have changed in libc++
28+
// and this test might not work anymore.
29+
// RUN: %{cxx} %s %{flags} %{compile_flags} %{link_flags} -fvisibility=hidden -fvisibility-inlines-hidden -shared -o %t.1.dylib
30+
// RUN: nm -m %t.1.dylib | c++filt | grep value > %t.1.symbols
31+
// RUN: grep weak %t.1.symbols
32+
33+
// Now, make sure that 'weak' goes away when we define _LIBCPP_DISABLE_AVAILABILITY.
34+
// In fact, all references to the function might go away, so we just check that we don't emit
35+
// any weak reference.
36+
// RUN: %{cxx} %s %{flags} %{compile_flags} %{link_flags} -fvisibility=hidden -fvisibility-inlines-hidden -D_LIBCPP_DISABLE_AVAILABILITY -shared -o %t.2.dylib
37+
// RUN: nm -m %t.2.dylib | c++filt | grep value > %t.2.symbols
38+
// RUN: not grep weak %t.2.symbols
39+
40+
#include <version>
41+
42+
template <class T>
43+
struct optional {
44+
T val_;
45+
_LIBCPP_HIDE_FROM_ABI _LIBCPP_INTRODUCED_IN_LLVM_11_ATTRIBUTE T value() const { return val_; }
46+
};
47+
48+
using PMF = int (optional<int>::*)() const;
49+
PMF f() { return &optional<int>::value; }

lld/COFF/Driver.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2639,10 +2639,8 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) {
26392639
createECExportThunks();
26402640

26412641
// Resolve remaining undefined symbols and warn about imported locals.
2642-
ctx.forEachSymtab([&](SymbolTable &symtab) {
2643-
while (symtab.resolveRemainingUndefines())
2644-
run();
2645-
});
2642+
ctx.forEachSymtab(
2643+
[&](SymbolTable &symtab) { symtab.resolveRemainingUndefines(); });
26462644

26472645
if (errorCount())
26482646
return;

lld/COFF/SymbolTable.cpp

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,8 @@ struct UndefinedDiag {
214214
std::vector<File> files;
215215
};
216216

217-
static void reportUndefinedSymbol(COFFLinkerContext &ctx,
217+
static void reportUndefinedSymbol(SymbolTable *symTab,
218+
COFFLinkerContext &ctx,
218219
const UndefinedDiag &undefDiag) {
219220
auto diag = errorOrWarn(ctx);
220221
diag << "undefined symbol: " << undefDiag.sym;
@@ -232,6 +233,17 @@ static void reportUndefinedSymbol(COFFLinkerContext &ctx,
232233
}
233234
if (numDisplayedRefs < numRefs)
234235
diag << "\n>>> referenced " << numRefs - numDisplayedRefs << " more times";
236+
237+
// Hints
238+
StringRef name = undefDiag.sym->getName();
239+
if (name.consume_front("__imp_")) {
240+
Symbol *imp = symTab->find(name);
241+
if (imp && imp->isLazy()) {
242+
diag << "\nNOTE: a relevant symbol '" << imp->getName()
243+
<< "' is available in " << toString(imp->getFile())
244+
<< " but cannot be used because it is not an import library.";
245+
}
246+
}
235247
}
236248

237249
void SymbolTable::loadMinGWSymbols() {
@@ -402,7 +414,7 @@ void SymbolTable::reportProblemSymbols(
402414
processFile(file, file->getSymbols());
403415

404416
for (const UndefinedDiag &undefDiag : undefDiags)
405-
reportUndefinedSymbol(ctx, undefDiag);
417+
reportUndefinedSymbol(this, ctx, undefDiag);
406418
}
407419

408420
void SymbolTable::reportUnresolvable() {
@@ -432,11 +444,10 @@ void SymbolTable::reportUnresolvable() {
432444
reportProblemSymbols(undefs, /*localImports=*/nullptr, true);
433445
}
434446

435-
bool SymbolTable::resolveRemainingUndefines() {
447+
void SymbolTable::resolveRemainingUndefines() {
436448
llvm::TimeTraceScope timeScope("Resolve remaining undefined symbols");
437449
SmallPtrSet<Symbol *, 8> undefs;
438450
DenseMap<Symbol *, Symbol *> localImports;
439-
bool foundLazy = false;
440451

441452
for (auto &i : symMap) {
442453
Symbol *sym = i.second;
@@ -481,11 +492,6 @@ bool SymbolTable::resolveRemainingUndefines() {
481492
imp = findLocalSym(*mangledName);
482493
}
483494
}
484-
if (imp && imp->isLazy()) {
485-
forceLazy(imp);
486-
foundLazy = true;
487-
continue;
488-
}
489495
if (imp && isa<Defined>(imp)) {
490496
auto *d = cast<Defined>(imp);
491497
replaceSymbol<DefinedLocalImport>(sym, ctx, name, d);
@@ -513,7 +519,6 @@ bool SymbolTable::resolveRemainingUndefines() {
513519
reportProblemSymbols(
514520
undefs, ctx.config.warnLocallyDefinedImported ? &localImports : nullptr,
515521
false);
516-
return foundLazy;
517522
}
518523

519524
std::pair<Symbol *, bool> SymbolTable::insert(StringRef name) {

0 commit comments

Comments
 (0)