Skip to content

Commit 55f7329

Browse files
committed
Merge "merge main into amd-staging" into amd-staging
2 parents c23c958 + 61f33ab commit 55f7329

File tree

302 files changed

+57113
-34940
lines changed

Some content is hidden

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

302 files changed

+57113
-34940
lines changed

.github/workflows/libclang-python-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,5 @@ jobs:
3737
projects: clang
3838
# There is an issue running on "windows-2019".
3939
# See https://github.com/llvm/llvm-project/issues/76601#issuecomment-1873049082.
40-
os_list: '["ubuntu-latest"]'
40+
os_list: '["ubuntu-22.04"]'
4141
python_version: ${{ matrix.python-version }}

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,12 @@ on:
3939
type: string
4040
# Use windows-2019 due to:
4141
# https://developercommunity.visualstudio.com/t/Prev-Issue---with-__assume-isnan-/1597317
42-
default: '["ubuntu-latest", "windows-2019", "macOS-13"]'
42+
# Use ubuntu-22.04 rather than ubuntu-latest to match the ubuntu
43+
# version in the CI container. Without this, setup-python tries
44+
# to install a python version linked against a newer version of glibc.
45+
# TODO(boomanaiden154): Bump the Ubuntu version once the version in the
46+
# container is bumped.
47+
default: '["ubuntu-22.04", "windows-2019", "macOS-13"]'
4348

4449
python_version:
4550
required: false
@@ -113,7 +118,8 @@ jobs:
113118
run: |
114119
if [ "${{ runner.os }}" == "Linux" ]; then
115120
builddir="/mnt/build/"
116-
mkdir -p $builddir
121+
sudo mkdir -p $builddir
122+
sudo chown gha $builddir
117123
extra_cmake_args="-DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_COMPILER=clang"
118124
else
119125
builddir="$(pwd)"/build

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-tools-extra/clang-tidy/misc/UnusedParametersCheck.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,11 @@
99
#include "UnusedParametersCheck.h"
1010
#include "clang/AST/ASTContext.h"
1111
#include "clang/AST/ASTLambda.h"
12+
#include "clang/AST/Attr.h"
13+
#include "clang/AST/Decl.h"
1214
#include "clang/AST/RecursiveASTVisitor.h"
1315
#include "clang/ASTMatchers/ASTMatchFinder.h"
16+
#include "clang/Basic/SourceManager.h"
1417
#include "clang/Lex/Lexer.h"
1518
#include "llvm/ADT/STLExtras.h"
1619
#include <unordered_map>
@@ -26,6 +29,17 @@ bool isOverrideMethod(const FunctionDecl *Function) {
2629
return MD->size_overridden_methods() > 0 || MD->hasAttr<OverrideAttr>();
2730
return false;
2831
}
32+
33+
bool hasAttrAfterParam(const SourceManager *SourceManager,
34+
const ParmVarDecl *Param) {
35+
for (const auto *Attr : Param->attrs()) {
36+
if (SourceManager->isBeforeInTranslationUnit(Param->getLocation(),
37+
Attr->getLocation())) {
38+
return true;
39+
}
40+
}
41+
return false;
42+
}
2943
} // namespace
3044

3145
void UnusedParametersCheck::registerMatchers(MatchFinder *Finder) {
@@ -189,6 +203,11 @@ void UnusedParametersCheck::check(const MatchFinder::MatchResult &Result) {
189203
if (Param->isUsed() || Param->isReferenced() || !Param->getDeclName() ||
190204
Param->hasAttr<UnusedAttr>())
191205
continue;
206+
if (hasAttrAfterParam(Result.SourceManager, Param)) {
207+
// Due to how grammar works, attributes would be wrongly applied to the
208+
// type if we remove the preceding parameter name.
209+
continue;
210+
}
192211

193212
// In non-strict mode ignore function definitions with empty bodies
194213
// (constructor initializer counts for non-empty body).

clang-tools-extra/docs/ReleaseNotes.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,10 @@ Changes in existing checks
350350
file path for anonymous enums in the diagnostic, and by fixing a typo in the
351351
diagnostic.
352352

353+
- Improved :doc:`readability-identifier-naming
354+
<clang-tidy/checks/readability/identifier-naming>` check to
355+
validate ``namespace`` aliases.
356+
353357
- Improved :doc:`readability-implicit-bool-conversion
354358
<clang-tidy/checks/readability/implicit-bool-conversion>` check
355359
by adding the option `UseUpperCaseLiteralSuffix` to select the
@@ -360,10 +364,6 @@ Changes in existing checks
360364
<clang-tidy/checks/readability/redundant-smartptr-get>` check to
361365
remove `->`, when redundant `get()` is removed.
362366

363-
- Improved :doc:`readability-identifier-naming
364-
<clang-tidy/checks/readability/identifier-naming>` check to
365-
validate ``namespace`` aliases.
366-
367367
Removed checks
368368
^^^^^^^^^^^^^^
369369

clang-tools-extra/test/clang-tidy/checkers/misc/unused-parameters.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,16 @@ void f(void (*fn)()) {;}
3333
// CHECK-MESSAGES: :[[@LINE-1]]:15: warning: parameter 'fn' is unused [misc-unused-parameters]
3434
// CHECK-FIXES: {{^}}void f(void (* /*fn*/)()) {;}{{$}}
3535

36+
int *k([[clang::lifetimebound]] int *i) {;}
37+
// CHECK-MESSAGES: :[[@LINE-1]]:38: warning: parameter 'i' is unused [misc-unused-parameters]
38+
// CHECK-FIXES: {{^}}int *k({{\[\[clang::lifetimebound\]\]}} int * /*i*/) {;}{{$}}
39+
40+
#define ATTR_BEFORE(x) [[clang::lifetimebound]] x
41+
int* m(ATTR_BEFORE(const int *i)) { return nullptr; }
42+
// CHECK-MESSAGES: :[[@LINE-1]]:31: warning: parameter 'i' is unused [misc-unused-parameters]
43+
// CHECK-FIXES: {{^}}int* m(ATTR_BEFORE(const int * /*i*/)) { return nullptr; }{{$}}
44+
#undef ATTR_BEFORE
45+
3646
// Unchanged cases
3747
// ===============
3848
void f(int i); // Don't remove stuff in declarations
@@ -42,6 +52,12 @@ void s(int i[1]);
4252
void u(void (*fn)());
4353
void w(int i) { (void)i; } // Don't remove used parameters
4454

55+
// Don't reanchor the attribute to the type:
56+
int *x(int *i [[clang::lifetimebound]]) { return nullptr; }
57+
#define ATTR_AFTER(x) x [[clang::lifetimebound]]
58+
int* y(ATTR_AFTER(const int *i)) { return nullptr; }
59+
#undef ATTR_AFTER
60+
4561
bool useLambda(int (*fn)(int));
4662
static bool static_var = useLambda([] (int a) { return a; });
4763

clang/cmake/modules/AddClang.cmake

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,13 +109,14 @@ macro(add_clang_library name)
109109
llvm_add_library(${name} ${LIBTYPE} ${ARG_UNPARSED_ARGUMENTS} ${srcs})
110110

111111
if(MSVC AND NOT CLANG_LINK_CLANG_DYLIB)
112-
# Make sure all consumers also turn off visibility macros so there not trying to dllimport symbols.
112+
# Make sure all consumers also turn off visibility macros so they're not
113+
# trying to dllimport symbols.
113114
target_compile_definitions(${name} PUBLIC CLANG_BUILD_STATIC)
114115
if(TARGET "obj.${name}")
115116
target_compile_definitions("obj.${name}" PUBLIC CLANG_BUILD_STATIC)
116117
endif()
117-
elseif(NOT ARG_SHARED AND NOT ARG_STATIC)
118-
# Clang component libraries linked in to clang-cpp are declared without SHARED or STATIC
118+
elseif(TARGET "obj.${name}" AND NOT ARG_SHARED AND NOT ARG_STATIC)
119+
# Clang component libraries linked to clang-cpp are declared without SHARED or STATIC
119120
target_compile_definitions("obj.${name}" PUBLIC CLANG_EXPORTS)
120121
endif()
121122

0 commit comments

Comments
 (0)