Skip to content

Commit 9f46c06

Browse files
authored
Merge branch 'main' into Fix_bug_61045
2 parents 7689da7 + a8e9dce commit 9f46c06

File tree

340 files changed

+12212
-8710
lines changed

Some content is hidden

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

340 files changed

+12212
-8710
lines changed

.github/workflows/llvm-project-tests.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ on:
1414
required: false
1515
os_list:
1616
required: false
17-
default: '["ubuntu-latest", "windows-2019", "macOS-12"]'
17+
default: '["ubuntu-latest", "windows-2019", "macOS-11"]'
1818
workflow_call:
1919
inputs:
2020
build_target:
@@ -34,7 +34,9 @@ on:
3434
type: string
3535
# Use windows-2019 due to:
3636
# https://developercommunity.visualstudio.com/t/Prev-Issue---with-__assume-isnan-/1597317
37-
default: '["ubuntu-latest", "windows-2019", "macOS-12"]'
37+
# We're using a specific version of macOS due to:
38+
# https://github.com/actions/virtual-environments/issues/5900
39+
default: '["ubuntu-latest", "windows-2019", "macOS-11"]'
3840

3941
concurrency:
4042
# Skip intermediate builds: always.
@@ -89,6 +91,10 @@ jobs:
8991
variant: sccache
9092
- name: Build and Test
9193
uses: llvm/actions/build-test-llvm-project@main
94+
env:
95+
# Workaround for https://github.com/actions/virtual-environments/issues/5900.
96+
# This should be a no-op for non-mac OSes
97+
PKG_CONFIG_PATH: /usr/local/Homebrew/Library/Homebrew/os/mac/pkgconfig//12
9298
with:
9399
cmake_args: '-GNinja -DLLVM_ENABLE_PROJECTS="${{ inputs.projects }}" -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_ASSERTIONS=ON -DLLDB_INCLUDE_TESTS=OFF -DCMAKE_C_COMPILER_LAUNCHER=sccache -DCMAKE_CXX_COMPILER_LAUNCHER=sccache ${{ inputs.extra_cmake_args }}'
94100
build_target: '${{ inputs.build_target }}'

bolt/test/RISCV/relax.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
// CHECK: Binary Function "_start" after building cfg {
88
// CHECK: jal ra, near_f
9-
// CHECK-NEXT: auipc ra, far_f@plt
9+
// CHECK-NEXT: auipc ra, far_f
1010
// CHECK-NEXT: jalr ra, 0xc(ra)
1111
// CHECK-NEXT: j near_f
1212

clang-tools-extra/clang-tidy/misc/UnusedUsingDeclsCheck.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ class UnusedUsingDeclsCheck : public ClangTidyCheck {
2626
void registerMatchers(ast_matchers::MatchFinder *Finder) override;
2727
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
2828
void onEndOfTranslationUnit() override;
29+
bool isLanguageVersionSupported(const LangOptions &LangOpts) const override {
30+
return LangOpts.CPlusPlus;
31+
}
2932

3033
private:
3134
void removeFromFoundDecls(const Decl *D);

clang-tools-extra/docs/ReleaseNotes.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ Changes in existing checks
382382

383383
- Improved :doc:`misc-unused-using-decls
384384
<clang-tidy/checks/misc/unused-using-decls>` check to avoid false positive when
385-
using in elaborated type.
385+
using in elaborated type and only check cpp files.
386386

387387
- Improved :doc:`modernize-avoid-bind
388388
<clang-tidy/checks/modernize/avoid-bind>` check to

clang/docs/ReleaseNotes.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1150,9 +1150,10 @@ Improvements
11501150
^^^^^^^^^^^^
11511151

11521152
- Improved the ``unix.StdCLibraryFunctions`` checker by modeling more
1153-
functions like ``send``, ``recv``, ``readlink``, ``fflush``, ``mkdtemp`` and
1154-
``errno`` behavior.
1153+
functions like ``send``, ``recv``, ``readlink``, ``fflush``, ``mkdtemp``,
1154+
``getcwd`` and ``errno`` behavior.
11551155
(`52ac71f92d38 <https://github.com/llvm/llvm-project/commit/52ac71f92d38f75df5cb88e9c090ac5fd5a71548>`_,
1156+
`#77040 <https://github.com/llvm/llvm-project/pull/77040>`_,
11561157
`#76671 <https://github.com/llvm/llvm-project/pull/76671>`_,
11571158
`#71373 <https://github.com/llvm/llvm-project/pull/71373>`_,
11581159
`#76557 <https://github.com/llvm/llvm-project/pull/76557>`_,

clang/include/clang/Analysis/CFG.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1215,7 +1215,9 @@ class CFG {
12151215
//===--------------------------------------------------------------------===//
12161216

12171217
class BuildOptions {
1218-
std::bitset<Stmt::lastStmtConstant> alwaysAddMask;
1218+
// Stmt::lastStmtConstant has the same value as the last Stmt kind,
1219+
// so make sure we add one to account for this!
1220+
std::bitset<Stmt::lastStmtConstant + 1> alwaysAddMask;
12191221

12201222
public:
12211223
using ForcedBlkExprs = llvm::DenseMap<const Stmt *, const CFGBlock *>;

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6160,23 +6160,19 @@ def err_illegal_initializer_type : Error<"illegal initializer type %0">;
61606160
def ext_init_list_type_narrowing : ExtWarn<
61616161
"type %0 cannot be narrowed to %1 in initializer list">,
61626162
InGroup<CXX11Narrowing>, DefaultError, SFINAEFailure;
6163-
// *_narrowing_const_reference diagnostics have the same messages, but are
6164-
// controlled by -Wc++11-narrowing-const-reference for narrowing involving a
6165-
// const reference.
61666163
def ext_init_list_type_narrowing_const_reference : ExtWarn<
6167-
"type %0 cannot be narrowed to %1 in initializer list">,
6164+
ext_init_list_type_narrowing.Summary>,
61686165
InGroup<CXX11NarrowingConstReference>, DefaultError, SFINAEFailure;
61696166
def ext_init_list_variable_narrowing : ExtWarn<
61706167
"non-constant-expression cannot be narrowed from type %0 to %1 in "
61716168
"initializer list">, InGroup<CXX11Narrowing>, DefaultError, SFINAEFailure;
61726169
def ext_init_list_variable_narrowing_const_reference : ExtWarn<
6173-
"non-constant-expression cannot be narrowed from type %0 to %1 in "
6174-
"initializer list">, InGroup<CXX11NarrowingConstReference>, DefaultError, SFINAEFailure;
6170+
ext_init_list_variable_narrowing.Summary>, InGroup<CXX11NarrowingConstReference>, DefaultError, SFINAEFailure;
61756171
def ext_init_list_constant_narrowing : ExtWarn<
61766172
"constant expression evaluates to %0 which cannot be narrowed to type %1">,
61776173
InGroup<CXX11Narrowing>, DefaultError, SFINAEFailure;
61786174
def ext_init_list_constant_narrowing_const_reference : ExtWarn<
6179-
"constant expression evaluates to %0 which cannot be narrowed to type %1">,
6175+
ext_init_list_constant_narrowing.Summary>,
61806176
InGroup<CXX11NarrowingConstReference>, DefaultError, SFINAEFailure;
61816177
def warn_init_list_type_narrowing : Warning<
61826178
"type %0 cannot be narrowed to %1 in initializer list in C++11">,

clang/include/clang/Basic/OpenACCKinds.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,11 @@ enum class OpenACCClauseKind {
9393
/// 'default' clause, allowed on parallel, serial, kernel (and compound)
9494
/// constructs.
9595
Default,
96+
/// 'if' clause, allowed on all the Compute Constructs, Data Constructs,
97+
/// Executable Constructs, and Combined Constructs.
98+
If,
99+
/// 'self' clause, allowed on Compute and Combined Constructs, plus 'update'.
100+
Self,
96101
/// Represents an invalid clause, for the purposes of parsing.
97102
Invalid,
98103
};

clang/include/clang/Driver/Options.td

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -773,6 +773,8 @@ def gcc_install_dir_EQ : Joined<["--"], "gcc-install-dir=">,
773773
def gcc_toolchain : Joined<["--"], "gcc-toolchain=">, Flags<[NoXarchOption]>,
774774
HelpText<"Specify a directory where Clang can find 'include' and 'lib{,32,64}/gcc{,-cross}/$triple/$version'. "
775775
"Clang will use the GCC installation with the largest version">;
776+
def gcc_triple_EQ : Joined<["--"], "gcc-triple=">,
777+
HelpText<"Search for the GCC installation with the specified triple.">;
776778
def CC : Flag<["-"], "CC">, Visibility<[ClangOption, CC1Option]>,
777779
Group<Preprocessor_Group>,
778780
HelpText<"Include comments from within macros in preprocessed output">,

clang/lib/AST/ASTImporter.cpp

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2034,23 +2034,25 @@ ASTNodeImporter::ImportDeclContext(DeclContext *FromDC, bool ForceImport) {
20342034
return ToDCOrErr.takeError();
20352035
}
20362036

2037-
DeclContext *ToDC = *ToDCOrErr;
2038-
// Remove all declarations, which may be in wrong order in the
2039-
// lexical DeclContext and then add them in the proper order.
2040-
for (auto *D : FromDC->decls()) {
2041-
if (!MightNeedReordering(D))
2042-
continue;
2037+
if (const auto *FromRD = dyn_cast<RecordDecl>(FromDC)) {
2038+
DeclContext *ToDC = *ToDCOrErr;
2039+
// Remove all declarations, which may be in wrong order in the
2040+
// lexical DeclContext and then add them in the proper order.
2041+
for (auto *D : FromRD->decls()) {
2042+
if (!MightNeedReordering(D))
2043+
continue;
20432044

2044-
assert(D && "DC contains a null decl");
2045-
if (Decl *ToD = Importer.GetAlreadyImportedOrNull(D)) {
2046-
// Remove only the decls which we successfully imported.
2047-
assert(ToDC == ToD->getLexicalDeclContext() && ToDC->containsDecl(ToD));
2048-
// Remove the decl from its wrong place in the linked list.
2049-
ToDC->removeDecl(ToD);
2050-
// Add the decl to the end of the linked list.
2051-
// This time it will be at the proper place because the enclosing for
2052-
// loop iterates in the original (good) order of the decls.
2053-
ToDC->addDeclInternal(ToD);
2045+
assert(D && "DC contains a null decl");
2046+
if (Decl *ToD = Importer.GetAlreadyImportedOrNull(D)) {
2047+
// Remove only the decls which we successfully imported.
2048+
assert(ToDC == ToD->getLexicalDeclContext() && ToDC->containsDecl(ToD));
2049+
// Remove the decl from its wrong place in the linked list.
2050+
ToDC->removeDecl(ToD);
2051+
// Add the decl to the end of the linked list.
2052+
// This time it will be at the proper place because the enclosing for
2053+
// loop iterates in the original (good) order of the decls.
2054+
ToDC->addDeclInternal(ToD);
2055+
}
20542056
}
20552057
}
20562058

clang/lib/AST/Interp/Interp.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -290,10 +290,10 @@ bool CheckInitialized(InterpState &S, CodePtr OpPC, const Pointer &Ptr,
290290
}
291291

292292
bool CheckLoad(InterpState &S, CodePtr OpPC, const Pointer &Ptr) {
293-
if (!CheckDummy(S, OpPC, Ptr))
294-
return false;
295293
if (!CheckLive(S, OpPC, Ptr, AK_Read))
296294
return false;
295+
if (!CheckDummy(S, OpPC, Ptr))
296+
return false;
297297
if (!CheckExtern(S, OpPC, Ptr))
298298
return false;
299299
if (!CheckRange(S, OpPC, Ptr, AK_Read))

clang/lib/AST/Interp/Interp.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1813,9 +1813,6 @@ inline bool ArrayElemPtr(InterpState &S, CodePtr OpPC) {
18131813
const T &Offset = S.Stk.pop<T>();
18141814
const Pointer &Ptr = S.Stk.peek<Pointer>();
18151815

1816-
if (!CheckArray(S, OpPC, Ptr))
1817-
return false;
1818-
18191816
if (!OffsetHelper<T, ArithOp::Add>(S, OpPC, Offset, Ptr))
18201817
return false;
18211818

@@ -1843,9 +1840,6 @@ inline bool ArrayElemPtrPop(InterpState &S, CodePtr OpPC) {
18431840
const T &Offset = S.Stk.pop<T>();
18441841
const Pointer &Ptr = S.Stk.pop<Pointer>();
18451842

1846-
if (!CheckArray(S, OpPC, Ptr))
1847-
return false;
1848-
18491843
if (!OffsetHelper<T, ArithOp::Add>(S, OpPC, Offset, Ptr))
18501844
return false;
18511845

clang/lib/Analysis/PathDiagnostic.cpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,7 @@
5050
using namespace clang;
5151
using namespace ento;
5252

53-
static StringRef StripTrailingDots(StringRef s) {
54-
for (StringRef::size_type i = s.size(); i != 0; --i)
55-
if (s[i - 1] != '.')
56-
return s.substr(0, i);
57-
return {};
58-
}
53+
static StringRef StripTrailingDots(StringRef s) { return s.rtrim('.'); }
5954

6055
PathDiagnosticPiece::PathDiagnosticPiece(StringRef s,
6156
Kind k, DisplayHint hint)

clang/lib/Basic/Targets/RISCV.cpp

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -237,22 +237,15 @@ ArrayRef<Builtin::Info> RISCVTargetInfo::getTargetBuiltins() const {
237237

238238
static std::vector<std::string>
239239
collectNonISAExtFeature(ArrayRef<std::string> FeaturesNeedOverride, int XLen) {
240-
auto ParseResult =
241-
llvm::RISCVISAInfo::parseFeatures(XLen, FeaturesNeedOverride);
242-
243-
if (!ParseResult) {
244-
consumeError(ParseResult.takeError());
245-
return std::vector<std::string>();
246-
}
247-
248-
std::vector<std::string> ImpliedFeatures = (*ParseResult)->toFeatureVector();
249-
250240
std::vector<std::string> NonISAExtFeatureVec;
251241

242+
auto IsNonISAExtFeature = [](const std::string &Feature) {
243+
assert(Feature.size() > 1 && (Feature[0] == '+' || Feature[0] == '-'));
244+
StringRef Ext = StringRef(Feature).drop_front(); // drop the +/-
245+
return !llvm::RISCVISAInfo::isSupportedExtensionFeature(Ext);
246+
};
252247
llvm::copy_if(FeaturesNeedOverride, std::back_inserter(NonISAExtFeatureVec),
253-
[&](const std::string &Feat) {
254-
return !llvm::is_contained(ImpliedFeatures, Feat);
255-
});
248+
IsNonISAExtFeature);
256249

257250
return NonISAExtFeatureVec;
258251
}

clang/lib/Driver/ToolChains/Gnu.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2251,6 +2251,15 @@ void Generic_GCC::GCCInstallationDetector::init(
22512251
return;
22522252
}
22532253

2254+
// If --gcc-triple is specified use this instead of trying to
2255+
// auto-detect a triple.
2256+
if (const Arg *A =
2257+
Args.getLastArg(clang::driver::options::OPT_gcc_triple_EQ)) {
2258+
StringRef GCCTriple = A->getValue();
2259+
CandidateTripleAliases.clear();
2260+
CandidateTripleAliases.push_back(GCCTriple);
2261+
}
2262+
22542263
// Compute the set of prefixes for our search.
22552264
SmallVector<std::string, 8> Prefixes;
22562265
StringRef GCCToolchainDir = getGCCToolchainDir(Args, D.SysRoot);

clang/lib/Format/TokenAnnotator.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5151,6 +5151,14 @@ bool TokenAnnotator::mustBreakBefore(const AnnotatedLine &Line,
51515151
return true;
51525152
if (Left.IsUnterminatedLiteral)
51535153
return true;
5154+
// FIXME: Breaking after newlines seems useful in general. Turn this into an
5155+
// option and recognize more cases like endl etc, and break independent of
5156+
// what comes after operator lessless.
5157+
if (Right.is(tok::lessless) && Right.Next &&
5158+
Right.Next->is(tok::string_literal) && Left.is(tok::string_literal) &&
5159+
Left.TokenText.ends_with("\\n\"")) {
5160+
return true;
5161+
}
51545162
if (Right.is(TT_RequiresClause)) {
51555163
switch (Style.RequiresClausePosition) {
51565164
case FormatStyle::RCPS_OwnLine:

clang/lib/Lex/ModuleMap.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -984,7 +984,9 @@ static void inferFrameworkLink(Module *Mod) {
984984
assert(!Mod->isSubFramework() &&
985985
"Can only infer linking for top-level frameworks");
986986

987-
Mod->LinkLibraries.push_back(Module::LinkLibrary(Mod->Name,
987+
StringRef FrameworkName(Mod->Name);
988+
FrameworkName.consume_back("_Private");
989+
Mod->LinkLibraries.push_back(Module::LinkLibrary(FrameworkName.str(),
988990
/*IsFramework=*/true));
989991
}
990992

clang/lib/Parse/ParseOpenACC.cpp

Lines changed: 47 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,10 @@ OpenACCClauseKind getOpenACCClauseKind(Token Tok) {
8080
if (Tok.is(tok::kw_default))
8181
return OpenACCClauseKind::Default;
8282

83+
// if is also a keyword, make sure we parse it correctly.
84+
if (Tok.is(tok::kw_if))
85+
return OpenACCClauseKind::If;
86+
8387
if (!Tok.is(tok::identifier))
8488
return OpenACCClauseKind::Invalid;
8589

@@ -88,9 +92,11 @@ OpenACCClauseKind getOpenACCClauseKind(Token Tok) {
8892
.Case("auto", OpenACCClauseKind::Auto)
8993
.Case("default", OpenACCClauseKind::Default)
9094
.Case("finalize", OpenACCClauseKind::Finalize)
95+
.Case("if", OpenACCClauseKind::If)
9196
.Case("if_present", OpenACCClauseKind::IfPresent)
9297
.Case("independent", OpenACCClauseKind::Independent)
9398
.Case("nohost", OpenACCClauseKind::NoHost)
99+
.Case("self", OpenACCClauseKind::Self)
94100
.Case("seq", OpenACCClauseKind::Seq)
95101
.Case("vector", OpenACCClauseKind::Vector)
96102
.Case("worker", OpenACCClauseKind::Worker)
@@ -323,8 +329,20 @@ OpenACCDirectiveKind ParseOpenACCDirectiveKind(Parser &P) {
323329
return DirKind;
324330
}
325331

332+
bool ClauseHasOptionalParens(OpenACCClauseKind Kind) {
333+
return Kind == OpenACCClauseKind::Self;
334+
}
335+
326336
bool ClauseHasRequiredParens(OpenACCClauseKind Kind) {
327-
return Kind == OpenACCClauseKind::Default;
337+
return Kind == OpenACCClauseKind::Default || Kind == OpenACCClauseKind::If;
338+
}
339+
340+
ExprResult ParseOpenACCConditionalExpr(Parser &P) {
341+
// FIXME: It isn't clear if the spec saying 'condition' means the same as
342+
// it does in an if/while/etc (See ParseCXXCondition), however as it was
343+
// written with Fortran/C in mind, we're going to assume it just means an
344+
// 'expression evaluating to boolean'.
345+
return P.getActions().CorrectDelayedTyposInExpr(P.ParseExpression());
328346
}
329347

330348
bool ParseOpenACCClauseParams(Parser &P, OpenACCClauseKind Kind) {
@@ -356,13 +374,36 @@ bool ParseOpenACCClauseParams(Parser &P, OpenACCClauseKind Kind) {
356374

357375
break;
358376
}
377+
case OpenACCClauseKind::If: {
378+
ExprResult CondExpr = ParseOpenACCConditionalExpr(P);
379+
// An invalid expression can be just about anything, so just give up on
380+
// this clause list.
381+
if (CondExpr.isInvalid())
382+
return true;
383+
break;
384+
}
359385
default:
360386
llvm_unreachable("Not a required parens type?");
361387
}
362388

363389
return Parens.consumeClose();
390+
} else if (ClauseHasOptionalParens(Kind)) {
391+
if (!Parens.consumeOpen()) {
392+
switch (Kind) {
393+
case OpenACCClauseKind::Self: {
394+
ExprResult CondExpr = ParseOpenACCConditionalExpr(P);
395+
// An invalid expression can be just about anything, so just give up on
396+
// this clause list.
397+
if (CondExpr.isInvalid())
398+
return true;
399+
break;
400+
}
401+
default:
402+
llvm_unreachable("Not an optional parens type?");
403+
}
404+
Parens.consumeClose();
405+
}
364406
}
365-
// FIXME: Handle optional parens
366407
return false;
367408
}
368409

@@ -372,8 +413,10 @@ bool ParseOpenACCClauseParams(Parser &P, OpenACCClauseKind Kind) {
372413
// However, they all are named with a single-identifier (or auto/default!)
373414
// token, followed in some cases by either braces or parens.
374415
bool ParseOpenACCClause(Parser &P) {
375-
if (!P.getCurToken().isOneOf(tok::identifier, tok::kw_auto, tok::kw_default))
376-
return P.Diag(P.getCurToken(), diag::err_expected) << tok::identifier;
416+
// A number of clause names are actually keywords, so accept a keyword that
417+
// can be converted to a name.
418+
if (expectIdentifierOrKeyword(P))
419+
return true;
377420

378421
OpenACCClauseKind Kind = getOpenACCClauseKind(P.getCurToken());
379422

clang/lib/Sema/SemaChecking.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18376,7 +18376,7 @@ static bool isSetterLikeSelector(Selector sel) {
1837618376
if (sel.isUnarySelector()) return false;
1837718377

1837818378
StringRef str = sel.getNameForSlot(0);
18379-
while (!str.empty() && str.front() == '_') str = str.substr(1);
18379+
str = str.ltrim('_');
1838018380
if (str.starts_with("set"))
1838118381
str = str.substr(3);
1838218382
else if (str.starts_with("add")) {

0 commit comments

Comments
 (0)