Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/issue-write.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:
- "Check code formatting"
- "Check for private emails used in PRs"
- "PR Request Release Note"
- "Code lint"
types:
- completed

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pr-code-format.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: "Check code formatting"
name: "Code lint"

permissions:
contents: read
Expand Down
123 changes: 123 additions & 0 deletions .github/workflows/pr-code-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
name: "Check code formatting"

permissions:
contents: read

on:
pull_request:
branches:
- main
- 'users/**'
paths:
- 'clang-tools-extra/clang-tidy/**'

jobs:
code_linter:
if: github.repository_owner == 'llvm'
runs-on: ubuntu-24.04
defaults:
run:
shell: bash
container:
image: 'ghcr.io/llvm/ci-ubuntu-24.04:latest'
timeout-minutes: 60
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
steps:
- name: Fetch LLVM sources
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
fetch-depth: 2

- name: Get changed files
id: changed-files
uses: step-security/changed-files@3dbe17c78367e7d60f00d78ae6781a35be47b4a1 # v45.0.1
with:
separator: ","
skip_initial_fetch: true
base_sha: 'HEAD~1'
sha: 'HEAD'

- name: Listed files
env:
CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }}
run: |
echo "Changed files:"
echo "$CHANGED_FILES"

- name: Fetch code linting utils
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.ref }}
sparse-checkout: |
llvm/utils/git/code-lint-helper.py
llvm/utils/git/requirements_linting.txt
clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py
sparse-checkout-cone-mode: false
path: code-lint-tools

- name: Install clang-tidy
uses: aminya/setup-cpp@17c11551771948abc5752bbf3183482567c7caf0 # v1.1.1
with:
clang-tidy: 20.1.8

- name: Setup Python env
uses: actions/setup-python@42375524e23c412d93fb67b49958b491fce71c38 # v5.4.0
with:
python-version: '3.12'

- name: Install Python dependencies
run: python3 -m pip install -r code-lint-tools/llvm/utils/git/requirements_linting.txt

# TODO: create special mapping for 'codegen' targets, for now build predefined set
# TODO: add entrypoint in 'compute_projects.py' that only adds a project and its direct dependencies
- name: Configure and CodeGen
run: |
git config --global --add safe.directory '*'

. <(git diff --name-only HEAD~1...HEAD | python3 .ci/compute_projects.py)

if [[ "${projects_to_build}" == "" ]]; then
echo "No projects to analyze"
exit 0
fi

cmake -G Ninja \
-B build \
-S llvm \
-DLLVM_ENABLE_ASSERTIONS=OFF \
-DLLVM_ENABLE_PROJECTS="${projects_to_build}" \
-DCMAKE_CXX_COMPILER=clang++ \
-DCMAKE_C_COMPILER=clang \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
-DLLVM_INCLUDE_TESTS=OFF \
-DCLANG_INCLUDE_TESTS=OFF \
-DCMAKE_BUILD_TYPE=Release

ninja -C build \
clang-tablegen-targets \
genconfusable # for "ConfusableIdentifierCheck.h"

- name: Run code linter
env:
GITHUB_PR_NUMBER: ${{ github.event.pull_request.number }}
CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }}
run: |
echo "[]" > comments &&
python3 ./code-lint-tools/llvm/utils/git/code-lint-helper.py \
--token ${{ secrets.GITHUB_TOKEN }} \
--issue-number $GITHUB_PR_NUMBER \
--start-rev HEAD~1 \
--end-rev HEAD \
--verbose \
--changed-files "$CHANGED_FILES"

- name: Upload results
uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 #v4.3.0
if: always()
with:
name: workflow-args
path: |
comments
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@ static void replaceCallWithArg(const CallExpr *Call, DiagnosticBuilder &Diag,
const LangOptions &LangOpts) {
const Expr *Arg = Call->getArg(0);

CharSourceRange BeforeArgumentsRange = Lexer::makeFileCharRange(
CharSourceRange beforeArgumentsRange = Lexer::makeFileCharRange(
CharSourceRange::getCharRange(Call->getBeginLoc(), Arg->getBeginLoc()),
SM, LangOpts);
CharSourceRange AfterArgumentsRange = Lexer::makeFileCharRange(
CharSourceRange::getCharRange(Call->getEndLoc(),
Call->getEndLoc().getLocWithOffset(1)),
SM, LangOpts);

if (BeforeArgumentsRange.isValid() && AfterArgumentsRange.isValid()) {
Diag << FixItHint::CreateRemoval(BeforeArgumentsRange)
if (beforeArgumentsRange.isValid() && AfterArgumentsRange.isValid()) {
Diag << FixItHint::CreateRemoval(beforeArgumentsRange)
<< FixItHint::CreateRemoval(AfterArgumentsRange);
}
}
Expand Down
6 changes: 3 additions & 3 deletions clang-tools-extra/clangd/AST.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ std::string getQualification(ASTContext &Context,
// Go over the declarations in reverse order, since we stored inner-most
// parent first.
NestedNameSpecifier Qualifier = std::nullopt;
bool IsFirst = true;
bool isFirst = true;
for (const auto *CurD : llvm::reverse(Parents)) {
if (auto *TD = llvm::dyn_cast<TagDecl>(CurD)) {
QualType T;
Expand All @@ -155,7 +155,7 @@ std::string getQualification(ASTContext &Context,
T = Context.getTemplateSpecializationType(
ElaboratedTypeKeyword::None,
Context.getQualifiedTemplateName(
Qualifier, /*TemplateKeyword=*/!IsFirst, TemplateName(CTD)),
Qualifier, /*TemplateKeyword=*/!isFirst, TemplateName(CTD)),
Args, /*CanonicalArgs=*/{}, Context.getCanonicalTagType(RD));
} else {
T = Context.getTagType(ElaboratedTypeKeyword::None, Qualifier, TD,
Expand All @@ -166,7 +166,7 @@ std::string getQualification(ASTContext &Context,
Qualifier =
NestedNameSpecifier(Context, cast<NamespaceDecl>(CurD), Qualifier);
}
IsFirst = false;
isFirst = false;
}
if (!Qualifier)
return "";
Expand Down
Loading
Loading