Skip to content

Commit

Permalink
clang-format updates
Browse files Browse the repository at this point in the history
  • Loading branch information
MikePopoloski committed Sep 9, 2022
1 parent 9bb9f84 commit fc5c4a0
Show file tree
Hide file tree
Showing 102 changed files with 1,513 additions and 1,407 deletions.
107 changes: 66 additions & 41 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -1,97 +1,122 @@
---
Language: Cpp
Language: Cpp
AccessModifierOffset: -4
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: false
AlignConsecutiveBitFields: false
AlignConsecutiveDeclarations: false
AlignConsecutiveMacros: false
AlignEscapedNewlines: Left
AlignOperands: true
AlignOperands: true
AlignTrailingComments: true
AllowAllArgumentsOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: false
AllowShortBlocksOnASingleLine: Never
AllowShortCaseLabelsOnASingleLine: false
AllowShortEnumsOnASingleLine: true
AllowShortFunctionsOnASingleLine: InlineOnly
AllowShortIfStatementsOnASingleLine: false
AllowShortIfStatementsOnASingleLine: Never
AllowShortLambdasOnASingleLine: All
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: true
AlwaysBreakTemplateDeclarations: Yes
BinPackArguments: true
BinPackParameters: true
BitFieldColonSpacing: Both
BraceWrapping:
AfterClass: false
AfterCaseLabel: false
AfterClass: false
AfterControlStatement: false
AfterEnum: false
AfterFunction: false
AfterNamespace: false
AfterObjCDeclaration: false
AfterStruct: false
AfterUnion: false
AfterExternBlock: false
BeforeCatch: true
BeforeElse: true
IndentBraces: false
SplitEmptyFunction: true
SplitEmptyRecord: true
SplitEmptyNamespace: true
AfterEnum: false
AfterFunction: false
AfterNamespace: false
AfterObjCDeclaration: false
AfterStruct: false
AfterUnion: false
AfterExternBlock: false
BeforeCatch: true
BeforeElse: true
BeforeLambdaBody: false
BeforeWhile: false
IndentBraces: false
SplitEmptyFunction: true
SplitEmptyRecord: true
SplitEmptyNamespace: true
BreakAfterJavaFieldAnnotations: false
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Custom
BreakBeforeInheritanceComma: false
#BreakBeforeConceptDeclarations: Always
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: false
BreakConstructorInitializers: AfterColon
BreakAfterJavaFieldAnnotations: false
BreakStringLiterals: true
ColumnLimit: 100
ColumnLimit: 100
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: false
Cpp11BracedListStyle: true
DeriveLineEnding: false
DerivePointerAlignment: false
DisableFormat: false
ExperimentalAutoDetectBinPacking: false
DisableFormat: false
EmptyLineAfterAccessModifier: Never
EmptyLineBeforeAccessModifier: LogicalBlock
FixNamespaceComments: true
IncludeBlocks: Regroup
IncludeBlocks: Regroup
IncludeCategories:
- Regex: '^"slang/'
Priority: 2
- Regex: '.*'
Priority: 1
IncludeIsMainRegex: '$'
IndentAccessModifiers: false
IndentCaseBlocks: false
IndentCaseLabels: true
IndentExternBlock: NoIndent
IndentGotoLabels: true
IndentPPDirectives: AfterHash
IndentWidth: 4
#IndentRequiresClause: true
IndentWidth: 4
IndentWrappedFunctionNames: false
KeepEmptyLinesAtTheStartOfBlocks: true
MacroBlockBegin: ''
MacroBlockEnd: ''
LambdaBodyIndentation: Signature
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
PenaltyBreakAssignment: 2
PenaltyBreakBeforeFirstCallParameter: 19
PackConstructorInitializers: BinPack
PenaltyBreakAssignment: 50
PenaltyBreakBeforeFirstCallParameter: 50
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 600
PointerAlignment: Left
ReflowComments: true
SortIncludes: true
QualifierAlignment: Leave
ReferenceAlignment: Left
ReflowComments: true
#RequiresClausePosition: WithPreceding
SortIncludes: CaseSensitive
SortUsingDeclarations: true
SpaceAfterCStyleCast: false
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: false
SpaceBeforeAssignmentOperators: true
SpaceBeforeCaseColon: false
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
SpaceBeforeRangeBasedForLoopColon: true
SpaceBeforeSquareBrackets: false
SpaceInEmptyBlock: false
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInContainerLiterals: true
SpacesInAngles: Never
SpacesInCStyleCastParentheses: false
SpacesInConditionalStatement: false
SpacesInContainerLiterals: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Cpp11
TabWidth: 4
UseTab: Never
Standard: Latest
TabWidth: 4
UseTab: Never
...
12 changes: 7 additions & 5 deletions bindings/python/binding.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -305,8 +305,9 @@ void registerBinding(py::module_& m) {
py::class_<EmptyArgumentExpression, Expression>(m, "EmptyArgumentExpression");

py::class_<TypeReferenceExpression, Expression>(m, "TypeReferenceExpression")
.def_property_readonly(
"targetType", [](const TypeReferenceExpression& self) { return &self.targetType; });
.def_property_readonly("targetType", [](const TypeReferenceExpression& self) {
return &self.targetType;
});

py::class_<HierarchicalReferenceExpression, Expression>(m, "HierarchicalReferenceExpression")
.def_readonly("symbol", &HierarchicalReferenceExpression::symbol);
Expand Down Expand Up @@ -547,9 +548,10 @@ void registerBinding(py::module_& m) {
.def_readonly("isFinal", &ImmediateAssertionStatement::isFinal);

py::class_<ConcurrentAssertionStatement, Statement>(m, "ConcurrentAssertionStatement")
.def_property_readonly(
"propertySpec",
[](const ConcurrentAssertionStatement& self) { return &self.propertySpec; })
.def_property_readonly("propertySpec",
[](const ConcurrentAssertionStatement& self) {
return &self.propertySpec;
})
.def_readonly("ifTrue", &ConcurrentAssertionStatement::ifTrue)
.def_readonly("ifFalse", &ConcurrentAssertionStatement::ifFalse)
.def_readonly("assertionKind", &ConcurrentAssertionStatement::assertionKind);
Expand Down
2 changes: 1 addition & 1 deletion bindings/python/numeric.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ void registerNumeric(py::module_& m) {
py::class_<ConstantRange>(m, "ConstantRange")
.def(py::init<>())
.def(py::init([](int left, int right) {
return ConstantRange{ left, right };
return ConstantRange{left, right};
}))
.def_readwrite("left", &ConstantRange::left)
.def_readwrite("right", &ConstantRange::right)
Expand Down
6 changes: 3 additions & 3 deletions bindings/python/pyslang.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,19 +49,19 @@ std::tuple<bool, span<T>> loadSpanFromBuffer(handle src) {
auto cleanup = ScopeGuard([&view] { PyBuffer_Release(&view); });
if (view.ndim == 1 && view.strides[0] == sizeof(T) &&
view.format[0] == format_descriptor<T>::c) {
return { true, span(static_cast<T*>(view.buf), view.shape[0]) };
return {true, span(static_cast<T*>(view.buf), view.shape[0])};
}
}
else {
// Clear the buffer error (failure is reported in the return value).
PyErr_Clear();
}
return { false, span<T>() };
return {false, span<T>()};
}
// If T is not a numeric type, the buffer interface cannot be used.
template<typename T, typename std::enable_if<!std::is_arithmetic<T>::value, bool>::type = true>
constexpr std::tuple<bool, span<T>> loadSpanFromBuffer(handle src) {
return { false, span<T>() };
return {false, span<T>()};
}

template<typename T>
Expand Down
17 changes: 10 additions & 7 deletions bindings/python/symbols.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,9 @@ void registerSymbols(py::module_& m) {
py::class_<TypeParameterSymbol, Symbol, ParameterSymbolBase>(m, "TypeParameterSymbol")
.def_property_readonly("targetType",
[](const TypeParameterSymbol& self) { return &self.targetType; })
.def_property_readonly(
"typeAlias", [](const TypeParameterSymbol& self) { return &self.getTypeAlias(); });
.def_property_readonly("typeAlias", [](const TypeParameterSymbol& self) {
return &self.getTypeAlias();
});

py::class_<DefParamSymbol, Symbol>(m, "DefParamSymbol")
.def_property_readonly("target",
Expand Down Expand Up @@ -386,9 +387,10 @@ void registerSymbols(py::module_& m) {
.def_property_readonly("isChecker", &UnknownModuleSymbol::isChecker);

py::class_<PrimitiveInstanceSymbol, InstanceSymbolBase>(m, "PrimitiveInstanceSymbol")
.def_property_readonly(
"primitiveType",
[](const PrimitiveInstanceSymbol& self) { return &self.primitiveType; })
.def_property_readonly("primitiveType",
[](const PrimitiveInstanceSymbol& self) {
return &self.primitiveType;
})
.def_property_readonly("portConnections", &PrimitiveInstanceSymbol::getPortConnections)
.def_property_readonly("delay", &PrimitiveInstanceSymbol::getDelay);

Expand Down Expand Up @@ -471,8 +473,9 @@ void registerSymbols(py::module_& m) {

py::class_<AssertionPortSymbol, Symbol>(m, "AssertionPortSymbol")
.def_readonly("localVarDirection", &AssertionPortSymbol::localVarDirection)
.def_property_readonly(
"type", [](const AssertionPortSymbol& self) { return &self.declaredType.getType(); });
.def_property_readonly("type", [](const AssertionPortSymbol& self) {
return &self.declaredType.getType();
});

py::class_<SequenceSymbol, Symbol, Scope>(m, "SequenceSymbol")
.def_readonly("ports", &SequenceSymbol::ports);
Expand Down
8 changes: 4 additions & 4 deletions bindings/python/syntax.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,10 @@ void registerSyntax(py::module_& m) {
py::class_<SyntaxTree, std::shared_ptr<SyntaxTree>>(m, "SyntaxTree")
.def_readonly("isLibrary", &SyntaxTree::isLibrary)
.def_static("fromFile", py::overload_cast<string_view>(&SyntaxTree::fromFile))
.def_static(
"fromFile",
py::overload_cast<string_view, SourceManager&, const Bag&>(&SyntaxTree::fromFile),
"path"_a, "sourceManager"_a, "options"_a = Bag())
.def_static("fromFile",
py::overload_cast<string_view, SourceManager&, const Bag&>(
&SyntaxTree::fromFile),
"path"_a, "sourceManager"_a, "options"_a = Bag())
.def_static("fromFiles", py::overload_cast<span<const string_view>>(&SyntaxTree::fromFiles))
.def_static("fromFiles",
py::overload_cast<span<const string_view>, SourceManager&, const Bag&>(
Expand Down
15 changes: 8 additions & 7 deletions bindings/python/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,10 @@ void registerUtil(py::module_& m) {
.def("assignText",
py::overload_cast<string_view, SourceLocation>(&SourceManager::assignText), "text"_a,
"includedFrom"_a = SourceLocation())
.def(
"assignText",
py::overload_cast<string_view, string_view, SourceLocation>(&SourceManager::assignText),
"path"_a, "text"_a, "includedFrom"_a = SourceLocation())
.def("assignText",
py::overload_cast<string_view, string_view, SourceLocation>(
&SourceManager::assignText),
"path"_a, "text"_a, "includedFrom"_a = SourceLocation())
.def("readSource", &SourceManager::readSource)
.def("readHeader", &SourceManager::readHeader)
.def("isCached", &SourceManager::isCached)
Expand Down Expand Up @@ -239,9 +239,10 @@ void registerUtil(py::module_& m) {
.def_static("reportAll", &DiagnosticEngine::reportAll);

py::class_<ReportedDiagnostic>(m, "ReportedDiagnostic")
.def_property_readonly(
"originalDiagnostic",
[](const ReportedDiagnostic& self) { return self.originalDiagnostic; })
.def_property_readonly("originalDiagnostic",
[](const ReportedDiagnostic& self) {
return self.originalDiagnostic;
})
.def_readonly("expansionLocs", &ReportedDiagnostic::expansionLocs)
.def_readonly("ranges", &ReportedDiagnostic::ranges)
.def_readonly("location", &ReportedDiagnostic::location)
Expand Down
4 changes: 2 additions & 2 deletions include/slang/binding/EvalContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@ class EvalContext {
/// object that when destructed will restore the previous caching mode.
/// Otherwise does nothing.
[[nodiscard]] auto disableCaching() {
auto guard =
ScopeGuard([this, saved = flags.has(EvalFlags::CacheResults), pushed = !inFunction()] {
auto guard = ScopeGuard(
[this, saved = flags.has(EvalFlags::CacheResults), pushed = !inFunction()] {
if (pushed)
popFrame();

Expand Down
2 changes: 1 addition & 1 deletion include/slang/binding/LValue.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class LValue {
LValue(LValue&& other) = default;

explicit LValue(Concat&& concat) : value(std::move(concat)) {}
explicit LValue(ConstantValue& base) : value(Path{ base }) {}
explicit LValue(ConstantValue& base) : value(Path{base}) {}

bool bad() const { return std::holds_alternative<std::monostate>(value); }
explicit operator bool() const { return !bad(); }
Expand Down
2 changes: 1 addition & 1 deletion include/slang/compilation/Compilation.h
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ class Compilation : public BumpAllocator {

// A table to look up scalar types based on combinations of the three flags: signed, fourstate,
// reg. Two of the entries are not valid and will be nullptr (!fourstate & reg).
Type* scalarTypeTable[8]{ nullptr };
Type* scalarTypeTable[8]{nullptr};

// Instances of all the built-in types.
Type* bitType;
Expand Down
4 changes: 2 additions & 2 deletions include/slang/mir/Instr.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,9 @@ class Instr {
InstrKind kind;

Instr(InstrKind kind, const Type& type, MIRValue op) noexcept :
type(type), kind(kind), immOps{ op, MIRValue{} } {}
type(type), kind(kind), immOps{op, MIRValue{}} {}
Instr(InstrKind kind, const Type& type, MIRValue op0, MIRValue op1) noexcept :
type(type), kind(kind), immOps{ op0, op1 } {}
type(type), kind(kind), immOps{op0, op1} {}

Instr(SysCallKind sysCall, const Type& returnType, span<const MIRValue> args) noexcept :
type(returnType), kind(InstrKind::syscall), sysCallKind(sysCall), varOps(args) {}
Expand Down
2 changes: 1 addition & 1 deletion include/slang/numeric/ConstantValue.h
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ struct ConstantRange {
bool isLittleEndian() const { return left >= right; }

/// Reverses the bit ordering of the range.
[[nodiscard]] ConstantRange reverse() const { return { right, left }; }
[[nodiscard]] ConstantRange reverse() const { return {right, left}; }

/// Selects a subrange of this range, correctly handling both forms of
/// bit endianness. This will assert that the given subrange is not wider.
Expand Down
8 changes: 4 additions & 4 deletions include/slang/numeric/MathUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ inline uint32_t countPopulation64(uint64_t value) {
inline std::optional<int32_t> checkedAddS32(int32_t a, int32_t b) {
#if defined(_MSC_VER)
int64_t p = int64_t(a) + int64_t(b);
bool fits =
p >= std::numeric_limits<int32_t>::min() && p <= std::numeric_limits<int32_t>::max();
bool fits = p >= std::numeric_limits<int32_t>::min() &&
p <= std::numeric_limits<int32_t>::max();
return fits ? std::make_optional(int32_t(p)) : std::nullopt;
#else
int32_t result;
Expand All @@ -89,8 +89,8 @@ inline std::optional<int32_t> checkedAddS32(int32_t a, int32_t b) {
inline std::optional<int32_t> checkedSubS32(int32_t a, int32_t b) {
#if defined(_MSC_VER)
int64_t p = int64_t(a) - int64_t(b);
bool fits =
p >= std::numeric_limits<int32_t>::min() && p <= std::numeric_limits<int32_t>::max();
bool fits = p >= std::numeric_limits<int32_t>::min() &&
p <= std::numeric_limits<int32_t>::max();
return fits ? std::make_optional(int32_t(p)) : std::nullopt;
#else
int32_t result;
Expand Down
4 changes: 2 additions & 2 deletions include/slang/parsing/NumberParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ class NumberParser {
Token value;
bool isSimple = true;

static IntResult simple(Token value) { return { Token(), Token(), value, true }; }
static IntResult simple(Token value) { return {Token(), Token(), value, true}; }

static IntResult vector(Token size, Token base, Token value) {
return { size, base, value, false };
return {size, base, value, false};
}
};

Expand Down
Loading

0 comments on commit fc5c4a0

Please sign in to comment.