Upgraded clang-format to 5.0 (#431)

This commit is contained in:
Tyler Veness
2017-11-11 22:09:51 -08:00
committed by Peter Johnson
parent 0001047b8b
commit 0c83cad70c
15 changed files with 96 additions and 67 deletions

View File

@@ -5,7 +5,7 @@ AccessModifierOffset: -1
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignEscapedNewlinesLeft: true
AlignEscapedNewlines: Left
AlignOperands: true
AlignTrailingComments: true
AllowAllParametersOfDeclarationOnNextLine: true
@@ -32,12 +32,20 @@ BraceWrapping:
BeforeCatch: false
BeforeElse: false
IndentBraces: false
SplitEmptyFunction: true
SplitEmptyRecord: true
SplitEmptyNamespace: true
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Attach
BreakBeforeInheritanceComma: false
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: false
BreakConstructorInitializers: BeforeColon
BreakAfterJavaFieldAnnotations: false
BreakStringLiterals: true
ColumnLimit: 80
CommentPragmas: '^ IWYU pragma:'
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: true
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
@@ -45,7 +53,11 @@ Cpp11BracedListStyle: true
DerivePointerAlignment: false
DisableFormat: false
ExperimentalAutoDetectBinPacking: false
ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ]
FixNamespaceComments: true
ForEachMacros:
- foreach
- Q_FOREACH
- BOOST_FOREACH
IncludeCategories:
- Regex: '^<.*\.h>'
Priority: 1
@@ -53,9 +65,12 @@ IncludeCategories:
Priority: 2
- Regex: '.*'
Priority: 3
IncludeIsMainRegex: '([-_](test|unittest))?$'
IndentCaseLabels: true
IndentWidth: 2
IndentWrappedFunctionNames: false
JavaScriptQuotes: Leave
JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: false
MacroBlockBegin: ''
MacroBlockEnd: ''
@@ -64,6 +79,7 @@ NamespaceIndentation: None
ObjCBlockIndentWidth: 2
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: false
PenaltyBreakAssignment: 2
PenaltyBreakBeforeFirstCallParameter: 1
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
@@ -73,7 +89,9 @@ PenaltyReturnTypeOnItsOwnLine: 200
PointerAlignment: Left
ReflowComments: true
SortIncludes: false
SortUsingDeclarations: true
SpaceAfterCStyleCast: false
SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeParens: ControlStatements
SpaceInEmptyParentheses: false

View File

@@ -1,4 +1,4 @@
sudo: false
sudo: true
dist: trusty
language: java
@@ -10,7 +10,12 @@ addons:
- g++-6
- python3
- python3-pip
- clang-format-3.8
before_install:
- sudo sh -c 'echo "deb http://apt.llvm.org/trusty/ llvm-toolchain-trusty-5.0 main" > /etc/apt/sources.list.d/llvm.list'
- wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key|sudo apt-key add -
- sudo apt-get update -q || true
- sudo apt-get install clang-format-5.0 -y
install:
- pip3 install --user wpiformat
@@ -28,6 +33,6 @@ cache:
- $HOME/.gradle/wrapper/
script:
- wpiformat -y 2017 -clang 3.8
- wpiformat -y 2017 -clang 5.0
- git --no-pager diff --exit-code HEAD # Ensure formatter made no changes
- ./gradlew --no-daemon --console=plain -PskipAthena :hal:halSimSharedLibrary :wpilibc:wpilibcSharedLibrary :wpilibj:wpilibJNISharedSharedLibrary :wpilibj:jar

View File

@@ -178,10 +178,10 @@ double HAL_ReadInterruptRisingTimestamp(HAL_InterruptHandle interruptHandle,
}
/**
* Return the timestamp for the falling interrupt that occurred most recently.
* This is in the same time domain as GetClock().
* @return Timestamp in seconds since boot.
*/
* Return the timestamp for the falling interrupt that occurred most recently.
* This is in the same time domain as GetClock().
* @return Timestamp in seconds since boot.
*/
double HAL_ReadInterruptFallingTimestamp(HAL_InterruptHandle interruptHandle,
int32_t* status) {
auto anInterrupt = interruptHandles.Get(interruptHandle);

View File

@@ -96,7 +96,7 @@ typedef Log FILELog;
if (level > FILELog::ReportingLevel()) \
; \
else \
Log().Get(level)
Log().Get(level)
inline std::string NowTime() {
llvm::SmallString<128> buf;

View File

@@ -84,8 +84,9 @@ IndexedClassedHandleResource<THandle, TStruct, size, enumValue>::Allocate(
template <typename THandle, typename TStruct, int16_t size,
HAL_HandleEnum enumValue>
std::shared_ptr<TStruct> IndexedClassedHandleResource<
THandle, TStruct, size, enumValue>::Get(THandle handle) {
std::shared_ptr<TStruct>
IndexedClassedHandleResource<THandle, TStruct, size, enumValue>::Get(
THandle handle) {
// get handle index, and fail early if index out of range or wrong handle
int16_t index = getHandleTypedIndex(handle, enumValue, m_version);
if (index < 0 || index >= size) {

View File

@@ -73,8 +73,9 @@ LimitedClassedHandleResource<THandle, TStruct, size, enumValue>::Allocate(
template <typename THandle, typename TStruct, int16_t size,
HAL_HandleEnum enumValue>
std::shared_ptr<TStruct> LimitedClassedHandleResource<
THandle, TStruct, size, enumValue>::Get(THandle handle) {
std::shared_ptr<TStruct>
LimitedClassedHandleResource<THandle, TStruct, size, enumValue>::Get(
THandle handle) {
// get handle index, and fail early if index out of range or wrong handle
int16_t index = getHandleTypedIndex(handle, enumValue, m_version);
if (index < 0 || index >= size) {

View File

@@ -120,8 +120,8 @@ PIDSubsystem::PIDSubsystem(double p, double i, double d, double f,
void PIDSubsystem::Enable() { m_controller->Enable(); }
/**
* Disables the internal {@link PIDController}.
*/
* Disables the internal {@link PIDController}.
*/
void PIDSubsystem::Disable() { m_controller->Disable(); }
/**

View File

@@ -116,8 +116,9 @@ Counter::Counter(const AnalogTrigger& trigger) : Counter(kTwoPulse) {
*/
Counter::Counter(EncodingType encodingType, DigitalSource* upSource,
DigitalSource* downSource, bool inverted)
: Counter(encodingType, std::shared_ptr<DigitalSource>(
upSource, NullDeleter<DigitalSource>()),
: Counter(encodingType,
std::shared_ptr<DigitalSource>(upSource,
NullDeleter<DigitalSource>()),
std::shared_ptr<DigitalSource>(downSource,
NullDeleter<DigitalSource>()),
inverted) {}

View File

@@ -81,10 +81,10 @@ void DigitalOutput::Set(bool value) {
}
/**
* Gets the value being output from the Digital Output.
*
* @return the state of the digital output.
*/
* Gets the value being output from the Digital Output.
*
* @return the state of the digital output.
*/
bool DigitalOutput::Get() const {
if (StatusIsFatal()) return false;

View File

@@ -168,7 +168,7 @@ double InterruptableSensorBase::ReadRisingTimestamp() {
* {@link #DigitalInput.SetUpSourceEdge}
*
* @return Timestamp in seconds since boot.
*/
*/
double InterruptableSensorBase::ReadFallingTimestamp() {
if (StatusIsFatal()) return 0.0;
wpi_assert(m_interrupt != HAL_kInvalidHandle);

View File

@@ -94,8 +94,9 @@ void LiveWindow::AddSensor(const std::string& subsystem,
void LiveWindow::AddSensor(const std::string& subsystem,
const std::string& name,
LiveWindowSendable& component) {
AddSensor(subsystem, name, std::shared_ptr<LiveWindowSendable>(
&component, [](LiveWindowSendable*) {}));
AddSensor(subsystem, name,
std::shared_ptr<LiveWindowSendable>(&component,
[](LiveWindowSendable*) {}));
}
/**
@@ -105,8 +106,9 @@ void LiveWindow::AddSensor(const std::string& subsystem,
void LiveWindow::AddSensor(const std::string& subsystem,
const std::string& name,
LiveWindowSendable* component) {
AddSensor(subsystem, name, std::shared_ptr<LiveWindowSendable>(
component, NullDeleter<LiveWindowSendable>()));
AddSensor(subsystem, name,
std::shared_ptr<LiveWindowSendable>(
component, NullDeleter<LiveWindowSendable>()));
}
//@}
@@ -137,8 +139,9 @@ void LiveWindow::AddActuator(const std::string& subsystem,
void LiveWindow::AddActuator(const std::string& subsystem,
const std::string& name,
LiveWindowSendable& component) {
AddActuator(subsystem, name, std::shared_ptr<LiveWindowSendable>(
&component, [](LiveWindowSendable*) {}));
AddActuator(subsystem, name,
std::shared_ptr<LiveWindowSendable>(&component,
[](LiveWindowSendable*) {}));
}
/**

View File

@@ -27,11 +27,11 @@ void SmartDashboard::init() {
}
/**
* Determines whether the given key is in this table.
*
* @param key the key to search for
* @return true if the table as a value assigned to the given key
*/
* Determines whether the given key is in this table.
*
* @param key the key to search for
* @return true if the table as a value assigned to the given key
*/
bool SmartDashboard::ContainsKey(llvm::StringRef key) {
return s_table->ContainsKey(key);
}
@@ -182,11 +182,11 @@ bool SmartDashboard::PutValue(llvm::StringRef keyName,
}
/**
* Gets the current value in the table, setting it if it does not exist.
* @param key the key
* @param defaultValue the default value to set if key doesn't exist.
* @returns False if the table key exists with a different type
*/
* Gets the current value in the table, setting it if it does not exist.
* @param key the key
* @param defaultValue the default value to set if key doesn't exist.
* @returns False if the table key exists with a different type
*/
bool SmartDashboard::SetDefaultValue(llvm::StringRef key,
std::shared_ptr<nt::Value> defaultValue) {
return s_table->GetEntry(key).SetDefaultValue(defaultValue);
@@ -218,11 +218,11 @@ bool SmartDashboard::PutBoolean(llvm::StringRef keyName, bool value) {
}
/**
* Gets the current value in the table, setting it if it does not exist.
* @param key the key
* @param defaultValue the default value to set if key doesn't exist.
* @returns False if the table key exists with a different type
*/
* Gets the current value in the table, setting it if it does not exist.
* @param key the key
* @param defaultValue the default value to set if key doesn't exist.
* @returns False if the table key exists with a different type
*/
bool SmartDashboard::SetDefaultBoolean(llvm::StringRef key, bool defaultValue) {
return s_table->GetEntry(key).SetDefaultBoolean(defaultValue);
}
@@ -254,11 +254,11 @@ bool SmartDashboard::PutNumber(llvm::StringRef keyName, double value) {
}
/**
* Gets the current value in the table, setting it if it does not exist.
* @param key the key
* @param defaultValue the default value to set if key doesn't exist.
* @returns False if the table key exists with a different type
*/
* Gets the current value in the table, setting it if it does not exist.
* @param key the key
* @param defaultValue the default value to set if key doesn't exist.
* @returns False if the table key exists with a different type
*/
bool SmartDashboard::SetDefaultNumber(llvm::StringRef key,
double defaultValue) {
return s_table->GetEntry(key).SetDefaultDouble(defaultValue);
@@ -315,15 +315,15 @@ std::string SmartDashboard::GetString(llvm::StringRef keyName,
}
/**
* Put a boolean array in the table
* @param key the key to be assigned to
* @param value the value that will be assigned
* @return False if the table key already exists with a different type
*
* @note The array must be of int's rather than of bool's because
* std::vector<bool> is special-cased in C++. 0 is false, any
* non-zero value is true.
*/
* Put a boolean array in the table
* @param key the key to be assigned to
* @param value the value that will be assigned
* @return False if the table key already exists with a different type
*
* @note The array must be of int's rather than of bool's because
* std::vector<bool> is special-cased in C++. 0 is false, any
* non-zero value is true.
*/
bool SmartDashboard::PutBooleanArray(llvm::StringRef key,
llvm::ArrayRef<int> value) {
return s_table->GetEntry(key).SetBooleanArray(value);

View File

@@ -34,8 +34,8 @@ TEST(NotifierTest, DISABLED_TestTimerNotifications) {
Wait(10.5);
llvm::outs() << "...Wait\n";
EXPECT_EQ(10u, notifierCounter) << "Received " << notifierCounter
<< " notifications in 10.5 seconds";
EXPECT_EQ(10u, notifierCounter)
<< "Received " << notifierCounter << " notifications in 10.5 seconds";
llvm::outs() << "Received " << notifierCounter
<< " notifications in 10.5 seconds";

View File

@@ -86,9 +86,9 @@ TEST_F(PIDToleranceTest, Percent) {
<< "Error was in tolerance when it should not have been. Error was "
<< pid->GetAvgError();
inp.val = setpoint +
(tolerance) / 200 *
range; // half of percent tolerance away from setpoint
inp.val =
setpoint + (tolerance) / 200 *
range; // half of percent tolerance away from setpoint
Wait(1.0);
EXPECT_TRUE(pid->OnTarget())

View File

@@ -103,10 +103,10 @@ void TiltPanCameraTest::GyroAngle() {
}
/**
* Gets calibrated parameters from previously calibrated gyro, allocates a new
* gyro with the given parameters for center and offset, and re-runs tests on
* the new gyro.
*/
* Gets calibrated parameters from previously calibrated gyro, allocates a new
* gyro with the given parameters for center and offset, and re-runs tests on
* the new gyro.
*/
void TiltPanCameraTest::GyroCalibratedParameters() {
uint32_t cCenter = m_gyro->GetCenter();
double cOffset = m_gyro->GetOffset();