Skip to content

Commit 4a0eb12

Browse files
committed
Merge remote-tracking branch 'origin/main' into vplan-remove-loop-region-instead-of-using-branch-on-cond-true
2 parents f0421c6 + 01463a2 commit 4a0eb12

File tree

685 files changed

+20448
-6210
lines changed

Some content is hidden

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

685 files changed

+20448
-6210
lines changed

bolt/lib/Core/HashUtilities.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ std::string hashBlockLoose(BinaryContext &BC, const BinaryBasicBlock &BB) {
145145
continue;
146146
}
147147

148-
std::string Mnemonic = BC.InstPrinter->getMnemonic(&Inst).first;
148+
std::string Mnemonic = BC.InstPrinter->getMnemonic(Inst).first;
149149
llvm::erase_if(Mnemonic, [](unsigned char ch) { return std::isspace(ch); });
150150
Opcodes.insert(Mnemonic);
151151
}

clang-tools-extra/clang-tidy/altera/IdDependentBackwardBranchCheck.cpp

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,33 +78,44 @@ void IdDependentBackwardBranchCheck::registerMatchers(MatchFinder *Finder) {
7878

7979
IdDependentBackwardBranchCheck::IdDependencyRecord *
8080
IdDependentBackwardBranchCheck::hasIdDepVar(const Expr *Expression) {
81+
if (!Expression)
82+
return nullptr;
83+
8184
if (const auto *Declaration = dyn_cast<DeclRefExpr>(Expression)) {
8285
// It is a DeclRefExpr, so check if it's an ID-dependent variable.
83-
const auto *CheckVariable = dyn_cast<VarDecl>(Declaration->getDecl());
86+
const auto *CheckVariable =
87+
dyn_cast_if_present<VarDecl>(Declaration->getDecl());
88+
if (!CheckVariable)
89+
return nullptr;
8490
auto FoundVariable = IdDepVarsMap.find(CheckVariable);
8591
if (FoundVariable == IdDepVarsMap.end())
8692
return nullptr;
8793
return &(FoundVariable->second);
8894
}
8995
for (const auto *Child : Expression->children())
90-
if (const auto *ChildExpression = dyn_cast<Expr>(Child))
96+
if (const auto *ChildExpression = dyn_cast_if_present<Expr>(Child))
9197
if (IdDependencyRecord *Result = hasIdDepVar(ChildExpression))
9298
return Result;
9399
return nullptr;
94100
}
95101

96102
IdDependentBackwardBranchCheck::IdDependencyRecord *
97103
IdDependentBackwardBranchCheck::hasIdDepField(const Expr *Expression) {
104+
if (!Expression)
105+
return nullptr;
106+
98107
if (const auto *MemberExpression = dyn_cast<MemberExpr>(Expression)) {
99108
const auto *CheckField =
100-
dyn_cast<FieldDecl>(MemberExpression->getMemberDecl());
109+
dyn_cast_if_present<FieldDecl>(MemberExpression->getMemberDecl());
110+
if (!CheckField)
111+
return nullptr;
101112
auto FoundField = IdDepFieldsMap.find(CheckField);
102113
if (FoundField == IdDepFieldsMap.end())
103114
return nullptr;
104115
return &(FoundField->second);
105116
}
106117
for (const auto *Child : Expression->children())
107-
if (const auto *ChildExpression = dyn_cast<Expr>(Child))
118+
if (const auto *ChildExpression = dyn_cast_if_present<Expr>(Child))
108119
if (IdDependencyRecord *Result = hasIdDepField(ChildExpression))
109120
return Result;
110121
return nullptr;

clang-tools-extra/clangd/XRefs.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2238,7 +2238,10 @@ prepareCallHierarchy(ParsedAST &AST, Position Pos, PathRef TUPath) {
22382238
for (const NamedDecl *Decl : getDeclAtPosition(AST, *Loc, {})) {
22392239
if (!(isa<DeclContext>(Decl) &&
22402240
cast<DeclContext>(Decl)->isFunctionOrMethod()) &&
2241-
Decl->getKind() != Decl::Kind::FunctionTemplate)
2241+
Decl->getKind() != Decl::Kind::FunctionTemplate &&
2242+
!(Decl->getKind() == Decl::Kind::Var &&
2243+
!cast<VarDecl>(Decl)->isLocalVarDecl()) &&
2244+
Decl->getKind() != Decl::Kind::Field)
22422245
continue;
22432246
if (auto CHI = declToCallHierarchyItem(*Decl, AST.tuPath()))
22442247
Result.emplace_back(std::move(*CHI));

clang-tools-extra/clangd/unittests/CallHierarchyTests.cpp

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,51 @@ TEST(CallHierarchy, CallInLocalVarDecl) {
446446
AllOf(from(withName("caller3")), fromRanges(Source.range("call3")))));
447447
}
448448

449+
TEST(CallHierarchy, HierarchyOnField) {
450+
// Tests that the call hierarchy works on fields.
451+
Annotations Source(R"cpp(
452+
struct Vars {
453+
int v^ar1 = 1;
454+
};
455+
void caller() {
456+
Vars values;
457+
values.$Callee[[var1]];
458+
}
459+
)cpp");
460+
TestTU TU = TestTU::withCode(Source.code());
461+
auto AST = TU.build();
462+
auto Index = TU.index();
463+
464+
std::vector<CallHierarchyItem> Items =
465+
prepareCallHierarchy(AST, Source.point(), testPath(TU.Filename));
466+
ASSERT_THAT(Items, ElementsAre(withName("var1")));
467+
auto IncomingLevel1 = incomingCalls(Items[0], Index.get());
468+
ASSERT_THAT(IncomingLevel1,
469+
ElementsAre(AllOf(from(withName("caller")),
470+
fromRanges(Source.range("Callee")))));
471+
}
472+
473+
TEST(CallHierarchy, HierarchyOnVar) {
474+
// Tests that the call hierarchy works on non-local variables.
475+
Annotations Source(R"cpp(
476+
int v^ar = 1;
477+
void caller() {
478+
$Callee[[var]];
479+
}
480+
)cpp");
481+
TestTU TU = TestTU::withCode(Source.code());
482+
auto AST = TU.build();
483+
auto Index = TU.index();
484+
485+
std::vector<CallHierarchyItem> Items =
486+
prepareCallHierarchy(AST, Source.point(), testPath(TU.Filename));
487+
ASSERT_THAT(Items, ElementsAre(withName("var")));
488+
auto IncomingLevel1 = incomingCalls(Items[0], Index.get());
489+
ASSERT_THAT(IncomingLevel1,
490+
ElementsAre(AllOf(from(withName("caller")),
491+
fromRanges(Source.range("Callee")))));
492+
}
493+
449494
} // namespace
450495
} // namespace clangd
451496
} // namespace clang

clang-tools-extra/docs/ReleaseNotes.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,10 @@ New check aliases
147147
Changes in existing checks
148148
^^^^^^^^^^^^^^^^^^^^^^^^^^
149149

150+
- Improved :doc:`altera-id-dependent-backward-branch
151+
<clang-tidy/checks/altera/id-dependent-backward-branch>` check by fixing
152+
crashes from invalid code.
153+
150154
- Improved :doc:`bugprone-casting-through-void
151155
<clang-tidy/checks/bugprone/casting-through-void>` check to suggest replacing
152156
the offending code with ``reinterpret_cast``, to more clearly express intent.

clang-tools-extra/test/clang-tidy/checkers/altera/id-dependent-backward-branch.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %check_clang_tidy %s altera-id-dependent-backward-branch %t -- -header-filter=.* "--" -cl-std=CL1.2 -c
1+
// RUN: %check_clang_tidy %s altera-id-dependent-backward-branch %t -- -header-filter=.* "--" -cl-std=CLC++1.0 -c
22

33
void error() {
44
// ==== Conditional Expressions ====
@@ -80,3 +80,9 @@ void success() {
8080
}
8181
}
8282
}
83+
84+
template<char... STOP>
85+
void gh55408(char const input[], int pos) {
86+
while (((input[pos] != STOP) && ...));
87+
}
88+

clang/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ If you're interested in more (including how to build Clang) it is best to read t
1616

1717
* Information on the LLVM project: http://llvm.org/
1818

19-
* If you have questions or comments about Clang, a great place to disucss them is on the Clang forums:    
19+
* If you have questions or comments about Clang, a great place to discuss them is on the Clang forums:    
2020

2121
[Clang Frontend - LLVM Discussion Forums](https://discourse.llvm.org/c/clang/)
2222

clang/docs/APINotes.rst

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,13 +169,31 @@ declaration kind), all of which are optional:
169169
to ``SWIFT_RETURNS_INDEPENDENT_VALUE``) or ``computed_property`` (equivalent to
170170
``SWIFT_COMPUTED_PROPERTY``).
171171

172+
::
173+
174+
Tags:
175+
- Name: OwnedStorage
176+
SwiftImportAs: owned
177+
178+
:SwiftRetainOp, SwiftReleaseOp:
179+
180+
Controls the lifetime operations of a class which uses custom reference
181+
counting. The class must be annotated as a reference type using
182+
``SwiftImportAs: reference``. The values are either names of global functions,
183+
each taking a single parameter of a pointer type, or ``immortal`` for a type
184+
that is considered alive for the duration of the program.
185+
172186
::
173187

174188
Tags:
175189
- Name: RefCountedStorage
176190
SwiftImportAs: reference
177191
SwiftReleaseOp: RCRelease
178192
SwiftRetainOp: RCRetain
193+
- Name: ImmortalSingleton
194+
SwiftImportAs: reference
195+
SwiftReleaseOp: immortal
196+
SwiftRetainOp: immortal
179197

180198
:SwiftCopyable:
181199

clang/docs/ClangFormatStyleOptions.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2259,7 +2259,7 @@ the configuration (without a prefix: ``Auto``).
22592259
**BraceWrapping** (``BraceWrappingFlags``) :versionbadge:`clang-format 3.8` :ref:`<BraceWrapping>`
22602260
Control of individual brace wrapping cases.
22612261

2262-
If ``BreakBeforeBraces`` is set to ``BS_Custom``, use this to specify how
2262+
If ``BreakBeforeBraces`` is set to ``Custom``, use this to specify how
22632263
each individual brace case should be handled. Otherwise, this is ignored.
22642264

22652265
.. code-block:: yaml

clang/docs/LanguageExtensions.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3979,9 +3979,9 @@ standard:
39793979
- ``4`` - to nearest, ties away from zero
39803980
The effect of passing some other value to ``__builtin_flt_rounds`` is
39813981
implementation-defined. ``__builtin_set_flt_rounds`` is currently only supported
3982-
to work on x86, x86_64, Arm and AArch64 targets. These builtins read and modify
3983-
the floating-point environment, which is not always allowed and may have unexpected
3984-
behavior. Please see the section on `Accessing the floating point environment <https://clang.llvm.org/docs/UsersManual.html#accessing-the-floating-point-environment>`_ for more information.
3982+
to work on x86, x86_64, powerpc, powerpc64, Arm and AArch64 targets. These builtins
3983+
read and modify the floating-point environment, which is not always allowed and may
3984+
have unexpected behavior. Please see the section on `Accessing the floating point environment <https://clang.llvm.org/docs/UsersManual.html#accessing-the-floating-point-environment>`_ for more information.
39853985
39863986
String builtins
39873987
---------------

0 commit comments

Comments
 (0)