Skip to content

Commit e66487f

Browse files
committed
Merge remote-tracking branch 'origin/main' into aballman-gh118660-second-bug
2 parents 530a889 + b4e17d4 commit e66487f

File tree

417 files changed

+42718
-36473
lines changed

Some content is hidden

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

417 files changed

+42718
-36473
lines changed

.github/workflows/containers/github-action-ci/Dockerfile

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ RUN apt-get update && \
5757
nodejs \
5858
perl-modules \
5959
python3-psutil \
60+
sudo \
6061

6162
# These are needed by the premerge pipeline. Pip is used to install
6263
# dependent python packages and ccache is used for build caching. File and
@@ -66,12 +67,28 @@ RUN apt-get update && \
6667
file \
6768
tzdata
6869

70+
# Install sccache as it is needed by most of the project test workflows and
71+
# cannot be installed by the ccache action when executing as a non-root user.
72+
# TODO(boomanaiden154): This should be switched to being installed with apt
73+
# once we bump to Ubuntu 24.04.
74+
RUN curl -L 'https://github.com/mozilla/sccache/releases/download/v0.7.6/sccache-v0.7.6-x86_64-unknown-linux-musl.tar.gz' > /tmp/sccache.tar.gz && \
75+
echo "2902a5e44c3342132f07b62e70cca75d9b23252922faf3b924f449808cc1ae58 /tmp/sccache.tar.gz" | sha256sum -c && \
76+
tar xzf /tmp/sccache.tar.gz -O --wildcards '*/sccache' > '/usr/local/bin/sccache' && \
77+
rm /tmp/sccache.tar.gz && \
78+
chmod +x /usr/local/bin/sccache
79+
6980
ENV LLVM_SYSROOT=$LLVM_SYSROOT
7081
ENV PATH=${LLVM_SYSROOT}/bin:${PATH}
7182

7283
# Create a new user to avoid test failures related to a lack of expected
7384
# permissions issues in some tests. Set the user id to 1001 as that is the
7485
# user id that Github Actions uses to perform the checkout action.
7586
RUN useradd gha -u 1001 -m -s /bin/bash
87+
88+
# Also add the user to passwordless sudoers so that we can install software
89+
# later on without having to rebuild the container.
90+
RUN adduser gha sudo
91+
RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
92+
7693
USER gha
7794

.github/workflows/premerge.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ jobs:
3131
- name: Setup ccache
3232
uses: hendrikmuhs/[email protected]
3333
- name: Build and Test
34+
# Mark the job as a success even if the step fails so that people do
35+
# not get notified while the new premerge pipeline is in an
36+
# experimental state.
37+
# TODO(boomanaiden154): Remove this once the pipeline is stable and we
38+
# are ready for people to start recieving notifications.
39+
continue-on-error: true
3440
run: |
3541
git config --global --add safe.directory '*'
3642

clang-tools-extra/clang-tidy/bugprone/UnusedLocalNonTrivialVariableCheck.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "clang/ASTMatchers/ASTMatchFinder.h"
1616
#include "clang/ASTMatchers/ASTMatchers.h"
1717
#include "clang/ASTMatchers/ASTMatchersMacros.h"
18+
#include "clang/Basic/LangOptions.h"
1819

1920
using namespace clang::ast_matchers;
2021
using namespace clang::tidy::matchers;
@@ -29,9 +30,10 @@ static constexpr StringRef DefaultIncludeTypeRegex =
2930

3031
AST_MATCHER(VarDecl, isLocalVarDecl) { return Node.isLocalVarDecl(); }
3132
AST_MATCHER(VarDecl, isReferenced) { return Node.isReferenced(); }
32-
AST_MATCHER_P(VarDecl, explicitMarkUnused, LangOptions, LangOpts) {
33+
AST_MATCHER(VarDecl, explicitMarkUnused) {
3334
// Implementations should not emit a warning that a name-independent
3435
// declaration is used or unused.
36+
LangOptions const &LangOpts = Finder->getASTContext().getLangOpts();
3537
return Node.hasAttr<UnusedAttr>() ||
3638
(LangOpts.CPlusPlus26 && Node.isPlaceholderVar(LangOpts));
3739
}
@@ -66,7 +68,7 @@ void UnusedLocalNonTrivialVariableCheck::registerMatchers(MatchFinder *Finder) {
6668
varDecl(isLocalVarDecl(), unless(isReferenced()),
6769
unless(isExceptionVariable()), hasLocalStorage(), isDefinition(),
6870
unless(hasType(isReferenceType())), unless(hasType(isTrivial())),
69-
unless(explicitMarkUnused(getLangOpts())),
71+
unless(explicitMarkUnused()),
7072
hasType(hasUnqualifiedDesugaredType(
7173
anyOf(recordType(hasDeclaration(namedDecl(
7274
matchesAnyListedName(IncludeTypes),

clang/docs/LibASTMatchersReference.html

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3462,6 +3462,21 @@ <h2 id="narrowing-matchers">Narrowing Matchers</h2>
34623462
</pre></td></tr>
34633463

34643464

3465+
<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1DependentNameType.html">DependentNameType</a>&gt;</td><td class="name" onclick="toggle('hasDependentName1')"><a name="hasDependentName1Anchor">hasDependentName</a></td><td>std::string N</td></tr>
3466+
<tr><td colspan="4" class="doc" id="hasDependentName1"><pre>Matches the dependent name of a DependentNameType.
3467+
3468+
Matches the dependent name of a DependentNameType
3469+
3470+
Given:
3471+
3472+
template &lt;typename T&lt; struct declToImport {
3473+
typedef typename T::type dependent_name;
3474+
};
3475+
3476+
dependentNameType(hasDependentName("type")) matches `T::type`
3477+
</pre></td></tr>
3478+
3479+
34653480
<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXDependentScopeMemberExpr.html">CXXDependentScopeMemberExpr</a>&gt;</td><td class="name" onclick="toggle('memberHasSameNameAsBoundNode0')"><a name="memberHasSameNameAsBoundNode0Anchor">memberHasSameNameAsBoundNode</a></td><td>std::string BindingID</td></tr>
34663481
<tr><td colspan="4" class="doc" id="memberHasSameNameAsBoundNode0"><pre>Matches template-dependent, but known, member names against an already-bound
34673482
node

clang/docs/OpenMPSupport.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,9 @@ implementation.
320320
+------------------------------+--------------------------------------------------------------+--------------------------+-----------------------------------------------------------------------+
321321
| misc | nothing directive | :good:`done` | D123286 |
322322
+------------------------------+--------------------------------------------------------------+--------------------------+-----------------------------------------------------------------------+
323-
| misc | masked construct and related combined constructs | :part:`worked on` | D99995, D100514 |
323+
| misc | masked construct and related combined constructs | :good:`done` | D99995, D100514, PR-121741(parallel_masked_taskloop) |
324+
| | | | PR-121746(parallel_masked_task_loop_simd),PR-121914(masked_taskloop) |
325+
| | | | PR-121916(masked_taskloop_simd) |
324326
+------------------------------+--------------------------------------------------------------+--------------------------+-----------------------------------------------------------------------+
325327
| misc | default(firstprivate) & default(private) | :good:`done` | D75591 (firstprivate), D125912 (private) |
326328
+------------------------------+--------------------------------------------------------------+--------------------------+-----------------------------------------------------------------------+

clang/docs/ReleaseNotes.rst

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1133,7 +1133,7 @@ AST Matchers
11331133

11341134
- Add ``dependentTemplateSpecializationType`` matcher to match a dependent template specialization type.
11351135

1136-
- Add ``hasDependentName`` matcher to match the dependent name of a DependentScopeDeclRefExpr.
1136+
- Add ``hasDependentName`` matcher to match the dependent name of a DependentScopeDeclRefExpr or DependentNameType.
11371137

11381138
clang-format
11391139
------------
@@ -1286,6 +1286,12 @@ Sanitizers
12861286
by the compiler (for example,
12871287
``-fno-sanitize-merge=bool,enum,array-bounds,local-bounds``).
12881288

1289+
- Changed ``-fsanitize=pointer-overflow`` to no longer report ``NULL + 0`` as
1290+
undefined behavior in C, in line with
1291+
`N3322 <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3322.pdf>`_,
1292+
and matching the previous behavior for C++.
1293+
``NULL + non_zero`` continues to be reported as undefined behavior.
1294+
12891295
Python Binding Changes
12901296
----------------------
12911297
- Fixed an issue that led to crashes when calling ``Type.get_exception_specification_kind``.
@@ -1300,6 +1306,8 @@ OpenMP Support
13001306
- Changed the OpenMP DeviceRTL to use 'generic' IR. The
13011307
``LIBOMPTARGET_DEVICE_ARCHITECTURES`` CMake argument is now unused and will
13021308
always build support for AMDGPU and NVPTX targets.
1309+
- Added support for combined masked constructs 'omp parallel masked taskloop',
1310+
'omp parallel masked taskloop simd','omp masked taskloop' and 'omp masked taskloop simd' directive.
13031311

13041312
Improvements
13051313
^^^^^^^^^^^^

clang/docs/UndefinedBehaviorSanitizer.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ Available checks are:
177177
problems at higher optimization levels.
178178
- ``-fsanitize=pointer-overflow``: Performing pointer arithmetic which
179179
overflows, or where either the old or new pointer value is a null pointer
180-
(or in C, when they both are).
180+
(excluding the case where both are null pointers).
181181
- ``-fsanitize=return``: In C++, reaching the end of a
182182
value-returning function without returning a value.
183183
- ``-fsanitize=returns-nonnull-attribute``: Returning null pointer

clang/include/clang/AST/OpenACCClause.h

Lines changed: 73 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -327,18 +327,89 @@ class OpenACCIfClause : public OpenACCClauseWithCondition {
327327
SourceLocation EndLoc);
328328
};
329329

330-
/// A 'self' clause, which has an optional condition expression.
331-
class OpenACCSelfClause : public OpenACCClauseWithCondition {
330+
/// A 'self' clause, which has an optional condition expression, or, in the
331+
/// event of an 'update' directive, contains a 'VarList'.
332+
class OpenACCSelfClause final
333+
: public OpenACCClauseWithParams,
334+
private llvm::TrailingObjects<OpenACCSelfClause, Expr *> {
335+
friend TrailingObjects;
336+
// Holds whether this HAS a condition expression. Lacks a value if this is NOT
337+
// a condition-expr self clause.
338+
std::optional<bool> HasConditionExpr;
339+
// Holds the number of stored expressions. In the case of a condition-expr
340+
// self clause, this is expected to be ONE (and there to be 1 trailing
341+
// object), whether or not that is null.
342+
unsigned NumExprs;
343+
332344
OpenACCSelfClause(SourceLocation BeginLoc, SourceLocation LParenLoc,
333345
Expr *ConditionExpr, SourceLocation EndLoc);
346+
OpenACCSelfClause(SourceLocation BeginLoc, SourceLocation LParenLoc,
347+
ArrayRef<Expr *> VarList, SourceLocation EndLoc);
348+
349+
// Intentionally internal, meant to be an implementation detail of everything
350+
// else. All non-internal uses should go through getConditionExpr/getVarList.
351+
llvm::ArrayRef<Expr *> getExprs() const {
352+
return {getTrailingObjects<Expr *>(), NumExprs};
353+
}
334354

335355
public:
336356
static bool classof(const OpenACCClause *C) {
337357
return C->getClauseKind() == OpenACCClauseKind::Self;
338358
}
359+
360+
bool isConditionExprClause() const { return HasConditionExpr.has_value(); }
361+
362+
bool hasConditionExpr() const {
363+
assert(HasConditionExpr.has_value() &&
364+
"VarList Self Clause asked about condition expression");
365+
return *HasConditionExpr;
366+
}
367+
368+
const Expr *getConditionExpr() const {
369+
assert(HasConditionExpr.has_value() &&
370+
"VarList Self Clause asked about condition expression");
371+
assert(getExprs().size() == 1 &&
372+
"ConditionExpr Self Clause with too many Exprs");
373+
return getExprs()[0];
374+
}
375+
376+
Expr *getConditionExpr() {
377+
assert(HasConditionExpr.has_value() &&
378+
"VarList Self Clause asked about condition expression");
379+
assert(getExprs().size() == 1 &&
380+
"ConditionExpr Self Clause with too many Exprs");
381+
return getExprs()[0];
382+
}
383+
384+
ArrayRef<Expr *> getVarList() {
385+
assert(!HasConditionExpr.has_value() &&
386+
"Condition Expr self clause asked about var list");
387+
return getExprs();
388+
}
389+
ArrayRef<Expr *> getVarList() const {
390+
assert(!HasConditionExpr.has_value() &&
391+
"Condition Expr self clause asked about var list");
392+
return getExprs();
393+
}
394+
395+
child_range children() {
396+
return child_range(
397+
reinterpret_cast<Stmt **>(getTrailingObjects<Expr *>()),
398+
reinterpret_cast<Stmt **>(getTrailingObjects<Expr *>() + NumExprs));
399+
}
400+
401+
const_child_range children() const {
402+
child_range Children = const_cast<OpenACCSelfClause *>(this)->children();
403+
return const_child_range(Children.begin(), Children.end());
404+
}
405+
339406
static OpenACCSelfClause *Create(const ASTContext &C, SourceLocation BeginLoc,
340407
SourceLocation LParenLoc,
341408
Expr *ConditionExpr, SourceLocation EndLoc);
409+
static OpenACCSelfClause *Create(const ASTContext &C, SourceLocation BeginLoc,
410+
SourceLocation LParenLoc,
411+
ArrayRef<Expr *> ConditionExpr,
412+
SourceLocation EndLoc);
342413
};
343414

344415
/// Represents a clause that has one or more expressions associated with it.

clang/include/clang/ASTMatchers/ASTMatchers.h

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3257,15 +3257,27 @@ AST_MATCHER_P(CXXDependentScopeMemberExpr, memberHasSameNameAsBoundNode,
32573257
});
32583258
}
32593259

3260-
/// Matches the dependent name of a DependentScopeDeclRefExpr
3260+
/// Matches the dependent name of a DependentScopeDeclRefExpr or
3261+
/// DependentNameType
32613262
///
32623263
/// Given:
32633264
/// \code
32643265
/// template <class T> class X : T { void f() { T::v; } };
32653266
/// \endcode
32663267
/// \c dependentScopeDeclRefExpr(hasDependentName("v")) matches `T::v`
3267-
AST_MATCHER_P(DependentScopeDeclRefExpr, hasDependentName, std::string, N) {
3268-
return Node.getDeclName().getAsString() == N;
3268+
///
3269+
/// Given:
3270+
/// \code
3271+
/// template <typename T> struct declToImport {
3272+
/// typedef typename T::type dependent_name;
3273+
/// };
3274+
/// \endcode
3275+
/// \c dependentNameType(hasDependentName("type")) matches `T::type`
3276+
AST_POLYMORPHIC_MATCHER_P(hasDependentName,
3277+
AST_POLYMORPHIC_SUPPORTED_TYPES(
3278+
DependentScopeDeclRefExpr, DependentNameType),
3279+
std::string, N) {
3280+
return internal::getDependentName(Node) == N;
32693281
}
32703282

32713283
/// Matches C++ classes that are directly or indirectly derived from a class
@@ -7724,7 +7736,7 @@ AST_MATCHER_P(DecayedType, hasDecayedType, internal::Matcher<QualType>,
77247736

77257737
/// Matches a dependent name type
77267738
///
7727-
/// Example matches T::type
7739+
/// Example matches T::type
77287740
/// \code
77297741
/// template <typename T> struct declToImport {
77307742
/// typedef typename T::type dependent_name;

clang/include/clang/ASTMatchers/ASTMatchersInternal.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2343,6 +2343,14 @@ MatchTemplateArgLocAt(const TemplateSpecializationTypeLoc &Node,
23432343
InnerMatcher.matches(Node.getArgLoc(Index), Finder, Builder);
23442344
}
23452345

2346+
inline std::string getDependentName(const DependentScopeDeclRefExpr &node) {
2347+
return node.getDeclName().getAsString();
2348+
}
2349+
2350+
inline std::string getDependentName(const DependentNameType &node) {
2351+
return node.getIdentifier()->getName().str();
2352+
}
2353+
23462354
} // namespace internal
23472355

23482356
} // namespace ast_matchers

0 commit comments

Comments
 (0)