8000 use C++17 [[fallthrough]] by ObiWahn · Pull Request #10280 · arangodb/arangodb · GitHub
[go: up one dir, main page]

Skip to content

use C++17 [[fallthrough]] #10280

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 19, 2019
Merged
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
4 changes: 2 additions & 2 deletions arangod/Aql/AllRowsFetcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ std::pair<ExecutionState, InputAqlItemRow> AllRowsFetcher::fetchRow(size_t atMos
_nextReturn = 0;
_dataFetchedState = DATA_FETCH_ONGOING;
}
// intentionally falls through
[[fallthrough]];
case DATA_FETCH_ONGOING: {
TRI_ASSERT(_nextReturn < _rowIndexes.size());
TRI_ASSERT(_aqlItemMatrix != nullptr);
Expand Down Expand Up @@ -258,4 +258,4 @@ std::pair<ExecutionState, ShadowAqlItemRow> AllRowsFetcher::fetchShadowRow(size_
}

return {state, row};
}
}
56 changes: 28 additions & 28 deletions arangod/Aql/AqlValue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,11 +241,11 @@ AqlValue AqlValue::at(int64_t position, bool& mustDestroy, bool doCopy) const {
switch (type()) {
case VPACK_SLICE_POINTER:
doCopy = false;
// intentionally falls through
[[fallthrough]];
case VPACK_INLINE:
// intentionally falls through
[[fallthrough]];
case VPACK_MANAGED_SLICE:
// intentionally falls through
[[fallthrough]];
case VPACK_MANAGED_BUFFER: {
VPackSlice s(slice());
if (s.isArray()) {
Expand Down Expand Up @@ -318,11 +318,11 @@ AqlValue AqlValue::at(int64_t position, size_t n, bool& mustDestroy, bool doCopy
switch (type()) {
case VPACK_SLICE_POINTER:
doCopy = false;
// intentionally falls through
[[fallthrough]];
case VPACK_INLINE:
// intentionally falls through
[[fallthrough]];
case VPACK_MANAGED_SLICE:
// intentionally falls through
[[fallthrough]];
case VPACK_MANAGED_BUFFER: {
VPackSlice s(slice());
if (s.isArray()) {
Expand Down Expand Up @@ -392,11 +392,11 @@ AqlValue AqlValue::getKeyAttribute(bool& mustDestroy, bool doCopy) const {
switch (type()) {
case VPACK_SLICE_POINTER:
doCopy = false;
// intentionally falls through
[[fallthrough]];
case VPACK_INLINE:
// intentionally falls through
[[fallthrough]];
case VPACK_MANAGED_SLICE:
// intentionally falls through
[[fallthrough]];
case VPACK_MANAGED_BUFFER: {
VPackSlice s(slice());
if (s.isObject()) {
Expand Down Expand Up @@ -431,11 +431,11 @@ AqlValue AqlValue::getIdAttribute(CollectionNameResolver const& resolver,
switch (type()) {
case VPACK_SLICE_POINTER:
doCopy = false;
// intentionally falls through
[[fallthrough]];
case VPACK_INLINE:
// intentionally falls through
[[fallthrough]];
case VPACK_MANAGED_SLICE:
// intentionally falls through
[[fallthrough]];
case VPACK_MANAGED_BUFFER: {
VPackSlice s(slice());
if (s.isObject()) {
Expand Down Expand Up @@ -474,11 +474,11 @@ AqlValue AqlValue::getFromAttribute(bool& mustDestroy, bool doCopy) const {
switch (type()) {
case VPACK_SLICE_POINTER:
doCopy = false;
// intentionally falls through
[[fallthrough]];
case VPACK_INLINE:
// intentionally falls through
[[fallthrough]];
case VPACK_MANAGED_SLICE:
// intentionally falls through
[[fallthrough]];
case VPACK_MANAGED_BUFFER: {
VPackSlice s(slice());
if (s.isObject()) {
Expand Down Expand Up @@ -512,11 +512,11 @@ AqlValue AqlValue::getToAttribute(bool& mustDestroy, bool doCopy) const {
switch (type()) {
case VPACK_SLICE_POINTER:
doCopy = false;
// intentionally falls through
[[fallthrough]];
case VPACK_INLINE:
// intentionally falls through
[[fallthrough]];
case VPACK_MANAGED_SLICE:
// intentionally falls through
[[fallthrough]];
case VPACK_MANAGED_BUFFER: {
VPackSlice s(slice());
if (s.isObject()) {
Expand Down Expand Up @@ -551,11 +551,11 @@ AqlValue AqlValue::get(CollectionNameResolver const& resolver,
switch (type()) {
case VPACK_SLICE_POINTER:
doCopy = false;
// intentionally falls through
[[fallthrough]];
case VPACK_INLINE:
// intentionally falls through
[[fallthrough]];
case VPACK_MANAGED_SLICE:
// intentionally falls through
[[fallthrough]];
case VPACK_MANAGED_BUFFER: {
VPackSlice s(slice());
if (s.isObject()) {
Expand Down Expand Up @@ -596,11 +596,11 @@ AqlValue AqlValue::get(CollectionNameResolver const& resolver,
< 8000 /td> switch (type()) {
case VPACK_SLICE_POINTER:
doCopy = false;
// intentionally falls through
[[fallthrough]];
case VPACK_INLINE:
// intentionally falls through
[[fallthrough]];
case VPACK_MANAGED_SLICE:
// intentionally falls through
[[fallthrough]];
case VPACK_MANAGED_BUFFER: {
VPackSlice s(slice());
if (s.isObject()) {
Expand Down Expand Up @@ -645,11 +645,11 @@ AqlValue AqlValue::get(CollectionNameResolver const& resolver,
switch (type()) {
case VPACK_SLICE_POINTER:
doCopy = false;
// intentionally falls through
[[fallthrough]];
case VPACK_INLINE:
// intentionally falls through
[[fallthrough]];
case VPACK_MANAGED_SLICE:
// intentionally falls through
[[fallthrough]];
case VPACK_MANAGED_BUFFER: {
VPackSlice s(slice());
if (s.isObject()) {
Expand Down Expand Up @@ -939,7 +939,7 @@ void AqlValue::toVelocyPack(transaction::Methods* trx, arangodb::velocypack::Bui
if (!resolveExternals && isManagedDocument()) {
builder.addExternal(_data.pointer);
break;
} // intentionally falls through
} [[fallthrough]];
case VPACK_INLINE:
case VPACK_MANAGED_SLICE:
case VPACK_MANAGED_BUFFER: {
Expand Down
62 changes: 31 additions & 31 deletions arangod/Aql/Functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ AqlValue timeAqlValue(ExpressionContext* expressionContext,

year_month_day ymd{floor<days>(tp)};
auto day_time = make_time(tp - sys_days(ymd));

auto y = static_cast<int>(ymd.year());
// quick sanity check here for dates outside the allowed range
if (y < 0 || y > 9999) {
Expand Down Expand Up @@ -439,7 +439,7 @@ AqlValue addOrSubtractUnitFromTimestamp(ExpressionContext* expressionContext,
break; // We are done
}
durationUnits *= 12;
// intentionally falls through
[[fallthrough]];
case MONTH:
durationUnits = std::modf(durationUnits, &intPart);
if (isSubtract) {
Expand All @@ -451,7 +451,7 @@ AqlValue addOrSubtractUnitFromTimestamp(ExpressionContext* expressionContext,
break; // We are done
}
durationUnits *= 30; // 1 Month ~= 30 Days
// intentionally falls through
[[fallthrough]];
// After this fall through the date may actually a bit off
case DAY:
// From here on we do not need leap-day handling
Expand Down Expand Up @@ -499,19 +499,19 @@ AqlValue addOrSubtractUnitFromTimestamp(ExpressionContext* expressionContext,

AqlValue addOrSubtractIsoDurationFromTimestamp(ExpressionContext* expressionContext,
tp_sys_clock_ms const& tp,
arangodb::velocypack::StringRef duration,
arangodb::velocypack::StringRef duration,
char const* AFN, bool isSubtract) {
year_month_day ymd{floor<days>(tp)};
auto day_time = make_time(tp - sys_days(ymd));

std::match_results<char const*> durationParts;
if (!basics::regexIsoDuration(duration, durationParts)) {
::registerWarning(expressionContext, AFN, TRI_ERROR_QUERY_INVALID_DATE_VALUE);
return AqlValue(AqlValueHintNull());
}

char const* begin;
char const* begin;

begin = duration.data() + durationParts.position(2);
int number = NumberUtils::atoi_unchecked<int>(begin, begin + durationParts.length(2));
if (isSubtract) {
Expand Down Expand Up @@ -2498,8 +2498,8 @@ void rtrimInternal(int32_t& startOffset, int32_t& endOffset, icu::UnicodeString&
if (unicodeStr.length() == 0) {
return;
}
for (int32_t codePos = unicodeStr.moveIndex32(endOffset, -1);
startOffset <= codePos;
for (int32_t codePos = unicodeStr.moveIndex32(endOffset, -1);
startOffset <= codePos;
codePos = unicodeStr.moveIndex32(codePos, -1)) {
bool found = false;

Expand Down Expand Up @@ -3648,47 +3648,47 @@ AqlValue Functions::DateCompare(ExpressionContext* expressionContext,
if (ymd1.year() != ymd2.year()) {
return AqlValue(AqlValueHintBool(false));
}
// intentionally falls through
[[fallthrough]];
case MONTH:
if (rangeEnd > MONTH) {
break;
}
if (ymd1.month() != ymd2.month()) {
return AqlValue(AqlValueHintBool(false));
}
// intentionally falls through
[[fallthrough]];
case DAY:
if (rangeEnd > DAY) {
break;
}
if (ymd1.day() != ymd2.day()) {
return AqlValue(AqlValueHintBool(false));
}
// intentionally falls through
[[fallthrough]];
case HOUR:
if (rangeEnd > HOUR) {
break;
}
if (time1.hours() != time2.hours()) {
return AqlValue(AqlValueHintBool(false));
}
// intentionally falls through
[[fallthrough]];
case MINUTE:
if (rangeEnd > MINUTE) {
break;
}
if (time1.minutes() != time2.minutes()) {
return AqlValue(AqlValueHintBool(false));
}
// intentionally falls through
[[fallthrough]];
case SECOND:
if (rangeEnd > SECOND) {
break;
}
if (time1.seconds() != time2.seconds()) {
return AqlValue(AqlValueHintBool(false));
}
// intentionally falls through
[[fallthrough]];
case MILLI:
if (rangeEnd > MILLI) {
break;
Expand Down Expand Up @@ -3730,15 +3730,15 @@ AqlValue Functions::DateRound(ExpressionContext* expressionContext,
::registerInvalidArgumentWarning(expressionContext, AFN);
return AqlValue(AqlValueHintNull());
}
int64_t const m = durationUnit.toInt64();

int64_t const m = durationUnit.toInt64();
if (m <= 0) {
::registerInvalidArgumentWarning(expressionContext, AFN);
return AqlValue(AqlValueHintNull());
}

velocypack::StringRef s = durationType.slice().stringRef();

int64_t factor = 1;
if (s == "milliseconds" || s == "millisecond" || s == "f") {
factor = 1;
Expand All @@ -3755,8 +3755,8 @@ AqlValue Functions::DateRound(ExpressionContext* expressionContext,
return AqlValue(AqlValueHintNull());
}

int64_t const multiplier = factor * m;
int64_t const multiplier = factor * m;

duration<int64_t, std::milli> time = tp.time_since_epoch();
int64_t t = time.count();
// integer division!
Expand Down Expand Up @@ -4186,7 +4186,7 @@ AqlValue Functions::Sleep(ExpressionContext* expressionContext,
}

auto& server = application_features::ApplicationServer::server();

double const sleepValue = value.toDouble();
auto now = std::chrono::steady_clock::now();
auto const endTime = now + std::chrono::milliseconds(static_cast<int64_t>(sleepValue * 1000.0));
Expand Down Expand Up @@ -4443,7 +4443,7 @@ AqlValue Functions::Unique(ExpressionContext* expressionContext, transaction::Me
std::unordered_set<VPackSlice, arangodb::basics::VelocyPackHelper::VPackHash, arangodb::basics::VelocyPackHelper::VPackEqual>
values(512, arangodb::basics::VelocyPackHelper::VPackHash(),
arangodb::basics::VelocyPackHelper::VPackEqual(options));

transaction::BuilderLeaser builder(trx);
builder->openArray();

Expand All @@ -4458,7 +4458,7 @@ AqlValue Functions::Unique(ExpressionContext* expressionContext, transaction::Me
builder->add(s);
}
}

builder->close();
return AqlValue(builder.get());
}
Expand Down Expand Up @@ -4845,7 +4845,7 @@ AqlValue Functions::GeoDistance(ExpressionContext* expressionContext,
::registerWarning(expressionContext, "GEO_DISTANCE", res);
return AqlValue(AqlValueHintNull());
}

if (parameters.size() > 2 && parameters[2].isString()) {
VPackValueLength len;
const char* ptr = parameters[2].slice().getStringUnchecked(len);
Expand Down Expand Up @@ -4911,17 +4911,17 @@ AqlValue Functions::GeoArea(ExpressionContext* expressionContext,
VPackFunctionParameters const& parameters) {
AqlValue p1 = extractFunctionParameterValue(parameters, 0);
AqlValue p2 = extractFunctionParameterValue(parameters, 1);

AqlValueMaterializer mat(trx);

geo::ShapeContainer shape;
Result res = geo::geojson::parseRegion(mat.slice(p1, true), shape);

if (res.fail()) {
::registerWarning(expressionContext, "GEO_AREA", res);
return AqlValue(AqlValueHintNull());
}

auto detEllipsoid = [](AqlValue const& p) {
if (p.isString()) {
VPackValueLength len;
Expand Down Expand Up @@ -7038,7 +7038,7 @@ AqlValue Functions::DecodeRev(ExpressionContext* expressionContext,
VPackValueLength l;
char const* p = rev.slice().getString(l);
uint64_t revInt = arangodb::basics::HybridLogicalClock::decodeTimeStamp(p, l);

if (revInt == 0 || revInt == UINT64_MAX) {
::registerInvalidArgumentWarning(expressionContext, "DECODE_REV");
return AqlValue(AqlValueHintNull());
Expand All @@ -7050,7 +7050,7 @@ AqlValue Functions::DecodeRev(ExpressionContext* expressionContext,
uint64_t millis = timeMilli % 1000;
struct tm date;
TRI_gmtime(timeSeconds, &date);

char buffer[32];
strftime(buffer, 32, "%Y-%m-%dT%H:%M:%S.000Z", &date);
// fill millisecond part not covered by strftime
Expand Down
40B0 Loading
0