Skip to content

Commit

Permalink
Update JIT sources to clang-format/clang-tidy 17.0.6 (dotnet#100498)
Browse files Browse the repository at this point in the history
* Update JIT sources to clang-format/clang-tidy 17.0.6

* Reformat

* Reformat x86
  • Loading branch information
BruceForstall authored Apr 3, 2024
1 parent f558631 commit 862c82f
Show file tree
Hide file tree
Showing 180 changed files with 4,572 additions and 3,622 deletions.
14 changes: 11 additions & 3 deletions eng/formatting/download-tools.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,25 @@ function DownloadClangTool {
$downloadOutputPath
)

$baseUri = "https://clrjit.blob.core.windows.net/clang-tools/windows"
$clangVersion = "17.0.6"
$clangToolsRootUrl = "https://clrjit2.blob.core.windows.net/clang-tools"
$clangPlatform = "windows-x64"

$toolUrl = "$clangToolsRootUrl/$clangVersion/$clangPlatform/$toolName.exe"
$targetPath = "$downloadOutputPath\$toolName.exe"

if (-not $(ls $downloadOutputPath | Where-Object { $_.Name -eq "$toolName.exe" })) {

Retry({
Write-Output "Downloading '$baseUri/$toolName.exe'"
Write-Output "Downloading '$toolUrl' to '$targetPath'"
# Pass -PassThru as otherwise Invoke-WebRequest leaves a corrupted file if the download fails. With -PassThru the download is buffered first.
# -UseBasicParsing is necessary for older PowerShells when Internet Explorer might not be installed/configured
$null = Invoke-WebRequest -Uri "$baseUri/$toolName.exe" -OutFile $(Join-Path $downloadOutputPath -ChildPath "$toolName.exe") -PassThru -UseBasicParsing
$null = Invoke-WebRequest -Uri "$toolUrl" -OutFile $(Join-Path $downloadOutputPath -ChildPath "$toolName.exe") -PassThru -UseBasicParsing
})
}
else {
Write-Output "Found '$targetPath'"
}
}

$downloadPathFolder = Split-Path $PSScriptRoot -Parent | Split-Path -Parent | Join-Path -ChildPath "artifacts" | Join-Path -ChildPath "tools"
Expand Down
21 changes: 11 additions & 10 deletions eng/formatting/download-tools.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,22 @@ done
scriptroot="$( cd -P "$( dirname "$source" )" && pwd )"

function DownloadClangTool {
targetPlatform=$(dotnet --info |grep RID:)
targetPlatform=${targetPlatform##*RID:* }
echo "dotnet RID: ${targetPlatform}"

clangVersion="17.0.6"
clangToolsRootUrl="https://clrjit2.blob.core.windows.net/clang-tools"

clangPlatform="$(dotnet --info | grep 'RID:')"
clangPlatform="${clangPlatform##*RID:* }"
echo "dotnet RID: ${clangPlatform}"

# override common RIDs with compatible version so we don't need to upload binaries for each RID
case $targetPlatform in
osx.*-x64)
targetPlatform=osx.10.15-x64
;;
case $clangPlatform in
ubuntu.*-x64)
targetPlatform=ubuntu.18.04-x64
;;
clangPlatform=linux-x64
;;
esac

toolUrl=https://clrjit.blob.core.windows.net/clang-tools/${targetPlatform}/$1
toolUrl="${clangToolsRootUrl}/${clangVersion}/${clangPlatform}/$1"
toolOutput=$2/$1

echo "Downloading $1 from ${toolUrl} to ${toolOutput}"
Expand Down
3 changes: 1 addition & 2 deletions eng/pipelines/coreclr/templates/format-job.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ jobs:
displayName: 'Install .NET SDK'
inputs:
packageType: 'sdk'
version: '6.x'
includePreviewVersions: true
version: '8.x'
installationPath: $(Agent.ToolsDirectory)/dotnet

- script: $(PythonSetupScript)
Expand Down
119 changes: 85 additions & 34 deletions src/coreclr/jit/.clang-format
Original file line number Diff line number Diff line change
@@ -1,80 +1,131 @@
---
Language: Cpp
Language: Cpp
AccessModifierOffset: -4
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: true
AlignConsecutiveDeclarations: true
AlignEscapedNewlinesLeft: false
AlignOperands: true
AlignTrailingComments: true

AlignConsecutiveAssignments:
Enabled: true
AcrossEmptyLines: false
AcrossComments: false
AlignCompound: false
PadOperators: true

AlignConsecutiveBitFields:
Enabled: true
AcrossEmptyLines: false
AcrossComments: false

AlignConsecutiveDeclarations:
Enabled: true
AcrossEmptyLines: false
AcrossComments: false

AlignConsecutiveMacros:
Enabled: true
AcrossEmptyLines: false
AcrossComments: false

AlignEscapedNewlines: Right
AlignOperands: true

AlignTrailingComments:
Kind: Always
OverEmptyLines: 0

AllowAllArgumentsOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: false
AllowShortBlocksOnASingleLine: Never
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: Empty
AllowShortIfStatementsOnASingleLine: false
AllowShortEnumsOnASingleLine: false
AllowShortFunctionsOnASingleLine: None
AllowShortIfStatementsOnASingleLine: Never
AllowShortLambdasOnASingleLine: Empty
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: true
BinPackArguments: true
BinPackParameters: false

BreakBeforeBraces: Custom
BraceWrapping:
AfterClass: true
AfterControlStatement: true
AfterEnum: false
AfterFunction: true
AfterNamespace: false
AfterObjCDeclaration: false
AfterStruct: true
AfterUnion: true
BeforeCatch: true
BeforeElse: true
IndentBraces: false
AfterCaseLabel: true
AfterClass: true
AfterControlStatement: Always
AfterEnum: true
AfterFunction: true
AfterNamespace: true
AfterStruct: true
AfterUnion: true
AfterExternBlock: true
BeforeCatch: true
BeforeElse: true
BeforeLambdaBody: false
BeforeWhile: false
IndentBraces: false
SplitEmptyFunction: true
SplitEmptyRecord: true
SplitEmptyNamespace: true

BreakBeforeBinaryOperators: None
BreakBeforeBraces: Allman
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: true
ColumnLimit: 120
CommentPragmas: '^ IWYU pragma:'
ConstructorInitializerAllOnOneLineOrOnePerLine: true
BreakConstructorInitializers: BeforeComma
BreakInheritanceList: BeforeComma
BreakStringLiterals: false

ColumnLimit: 120
CommentPragmas: '^ IWYU pragma:'
CompactNamespaces: false
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DerivePointerAlignment: false
DisableFormat: false
DisableFormat: false

EmptyLineAfterAccessModifier: Leave
EmptyLineBeforeAccessModifier: Leave
ExperimentalAutoDetectBinPacking: false
ForEachMacros: [ ]
ForEachMacros: [ ]
IndentAccessModifiers: false
IndentCaseBlocks: false
IndentCaseLabels: true
IndentWidth: 4
IndentExternBlock: false
IndentGotoLabels: true
IndentPPDirectives: None
IndentWidth: 4
IndentWrappedFunctionNames: false

InsertNewlineAtEOF: true
KeepEmptyLinesAtTheStartOfBlocks: true
LambdaBodyIndentation: OuterScope
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
ObjCBlockIndentWidth: 2
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true

PenaltyBreakBeforeFirstCallParameter: 400
PenaltyBreakComment: 50
PenaltyBreakFirstLessLess: 500
PenaltyBreakString: 1000
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 100000

PointerAlignment: Left
ReflowComments: true
SortIncludes: false
SortIncludes: Never

SpaceAfterCStyleCast: false
SpaceBeforeAssignmentOperators: true
SpaceBeforeParens: ControlStatements
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInAngles: false
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Cpp11

Standard: Latest
TabWidth: 4
UseTab: Never
...
19 changes: 14 additions & 5 deletions src/coreclr/jit/_typeinfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,25 +41,34 @@ class typeInfo
private:
var_types m_type;

union {
union
{
CORINFO_CLASS_HANDLE m_cls; // Valid, but not always available, for TYP_REFs.
methodPointerInfo* m_methodPointerInfo; // Valid only for function pointers.
};

public:
typeInfo() : m_type(TYP_UNDEF), m_cls(NO_CLASS_HANDLE)
typeInfo()
: m_type(TYP_UNDEF)
, m_cls(NO_CLASS_HANDLE)
{
}

typeInfo(var_types type) : m_type(type), m_cls(NO_CLASS_HANDLE)
typeInfo(var_types type)
: m_type(type)
, m_cls(NO_CLASS_HANDLE)
{
}

typeInfo(CORINFO_CLASS_HANDLE cls) : m_type(TYP_REF), m_cls(cls)
typeInfo(CORINFO_CLASS_HANDLE cls)
: m_type(TYP_REF)
, m_cls(cls)
{
}

typeInfo(methodPointerInfo* methodPointerInfo) : m_type(TYP_I_IMPL), m_methodPointerInfo(methodPointerInfo)
typeInfo(methodPointerInfo* methodPointerInfo)
: m_type(TYP_I_IMPL)
, m_methodPointerInfo(methodPointerInfo)
{
assert(methodPointerInfo != nullptr);
assert(methodPointerInfo->m_token.hMethod != nullptr);
Expand Down
7 changes: 5 additions & 2 deletions src/coreclr/jit/abi.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ class RegisterQueue
unsigned int m_index = 0;

public:
RegisterQueue(const regNumber* regs, unsigned int numRegs) : m_regs(regs), m_numRegs(numRegs)
RegisterQueue(const regNumber* regs, unsigned int numRegs)
: m_regs(regs)
, m_numRegs(numRegs)
{
}

Expand Down Expand Up @@ -187,7 +189,8 @@ class SwiftABIClassifier
PlatformClassifier m_classifier;

public:
SwiftABIClassifier(const ClassifierInfo& info) : m_classifier(info)
SwiftABIClassifier(const ClassifierInfo& info)
: m_classifier(info)
{
}

Expand Down
5 changes: 4 additions & 1 deletion src/coreclr/jit/alloc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@ size_t ArenaAllocator::getDefaultPageSize()
// ArenaAllocator::ArenaAllocator:
// Default-constructs an arena allocator.
ArenaAllocator::ArenaAllocator()
: m_firstPage(nullptr), m_lastPage(nullptr), m_nextFreeByte(nullptr), m_lastFreeByte(nullptr)
: m_firstPage(nullptr)
, m_lastPage(nullptr)
, m_nextFreeByte(nullptr)
, m_lastFreeByte(nullptr)
{
#if MEASURE_MEM_ALLOC
memset(&m_stats, 0, sizeof(m_stats));
Expand Down
13 changes: 7 additions & 6 deletions src/coreclr/jit/alloc.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ enum CompMemKind
class ArenaAllocator
{
private:
ArenaAllocator(const ArenaAllocator& other) = delete;
ArenaAllocator(const ArenaAllocator& other) = delete;
ArenaAllocator& operator=(const ArenaAllocator& other) = delete;
ArenaAllocator& operator=(ArenaAllocator&& other) = delete;
ArenaAllocator& operator=(ArenaAllocator&& other) = delete;

struct PageDescriptor
{
Expand Down Expand Up @@ -52,7 +52,7 @@ class ArenaAllocator
void* allocateNewPage(size_t size);

static void* allocateHostMemory(size_t size, size_t* pActualSize);
static void freeHostMemory(void* block, size_t size);
static void freeHostMemory(void* block, size_t size);

#if MEASURE_MEM_ALLOC
struct MemStats
Expand Down Expand Up @@ -125,8 +125,8 @@ class ArenaAllocator

public:
MemStatsAllocator* getMemStatsAllocator(CompMemKind kind);
void finishMemStats();
void dumpMemStats(FILE* file);
void finishMemStats();
void dumpMemStats(FILE* file);

static void dumpMaxMemStats(FILE* file);
static void dumpAggregateMemStats(FILE* file);
Expand Down Expand Up @@ -276,7 +276,8 @@ class CompIAllocator : public IAllocator
char m_zeroLenAllocTarg;

public:
CompIAllocator(CompAllocator alloc) : m_alloc(alloc)
CompIAllocator(CompAllocator alloc)
: m_alloc(alloc)
{
}

Expand Down
3 changes: 2 additions & 1 deletion src/coreclr/jit/arraystack.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ class ArrayStack
static const int builtinSize = 8;

public:
explicit ArrayStack(CompAllocator alloc, int initialCapacity = builtinSize) : m_alloc(alloc)
explicit ArrayStack(CompAllocator alloc, int initialCapacity = builtinSize)
: m_alloc(alloc)
{
if (initialCapacity > builtinSize)
{
Expand Down
Loading

0 comments on commit 862c82f

Please sign in to comment.