|
@@ -1041,11 +1041,12 @@ private:
|
|
|
|
|
|
// Iterate through all lines and remove any empty (nested) namespaces.
|
|
// Iterate through all lines and remove any empty (nested) namespaces.
|
|
void checkEmptyNamespace(SmallVectorImpl<AnnotatedLine *> &AnnotatedLines) {
|
|
void checkEmptyNamespace(SmallVectorImpl<AnnotatedLine *> &AnnotatedLines) {
|
|
|
|
+ std::set<unsigned> DeletedLines;
|
|
for (unsigned i = 0, e = AnnotatedLines.size(); i != e; ++i) {
|
|
for (unsigned i = 0, e = AnnotatedLines.size(); i != e; ++i) {
|
|
auto &Line = *AnnotatedLines[i];
|
|
auto &Line = *AnnotatedLines[i];
|
|
if (Line.startsWith(tok::kw_namespace) ||
|
|
if (Line.startsWith(tok::kw_namespace) ||
|
|
Line.startsWith(tok::kw_inline, tok::kw_namespace)) {
|
|
Line.startsWith(tok::kw_inline, tok::kw_namespace)) {
|
|
- checkEmptyNamespace(AnnotatedLines, i, i);
|
|
|
|
|
|
+ checkEmptyNamespace(AnnotatedLines, i, i, DeletedLines);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1063,7 +1064,8 @@ private:
|
|
// sets \p NewLine to the last line checked.
|
|
// sets \p NewLine to the last line checked.
|
|
// Returns true if the current namespace is empty.
|
|
// Returns true if the current namespace is empty.
|
|
bool checkEmptyNamespace(SmallVectorImpl<AnnotatedLine *> &AnnotatedLines,
|
|
bool checkEmptyNamespace(SmallVectorImpl<AnnotatedLine *> &AnnotatedLines,
|
|
- unsigned CurrentLine, unsigned &NewLine) {
|
|
|
|
|
|
+ unsigned CurrentLine, unsigned &NewLine,
|
|
|
|
+ std::set<unsigned> &DeletedLines) {
|
|
unsigned InitLine = CurrentLine, End = AnnotatedLines.size();
|
|
unsigned InitLine = CurrentLine, End = AnnotatedLines.size();
|
|
if (Style.BraceWrapping.AfterNamespace) {
|
|
if (Style.BraceWrapping.AfterNamespace) {
|
|
// If the left brace is in a new line, we should consume it first so that
|
|
// If the left brace is in a new line, we should consume it first so that
|
|
@@ -1083,7 +1085,8 @@ private:
|
|
if (AnnotatedLines[CurrentLine]->startsWith(tok::kw_namespace) ||
|
|
if (AnnotatedLines[CurrentLine]->startsWith(tok::kw_namespace) ||
|
|
AnnotatedLines[CurrentLine]->startsWith(tok::kw_inline,
|
|
AnnotatedLines[CurrentLine]->startsWith(tok::kw_inline,
|
|
tok::kw_namespace)) {
|
|
tok::kw_namespace)) {
|
|
- if (!checkEmptyNamespace(AnnotatedLines, CurrentLine, NewLine))
|
|
|
|
|
|
+ if (!checkEmptyNamespace(AnnotatedLines, CurrentLine, NewLine,
|
|
|
|
+ DeletedLines))
|
|
return false;
|
|
return false;
|
|
CurrentLine = NewLine;
|
|
CurrentLine = NewLine;
|
|
continue;
|
|
continue;
|
|
@@ -1208,8 +1211,6 @@ private:
|
|
|
|
|
|
// Tokens to be deleted.
|
|
// Tokens to be deleted.
|
|
std::set<FormatToken *, FormatTokenLess> DeletedTokens;
|
|
std::set<FormatToken *, FormatTokenLess> DeletedTokens;
|
|
- // The line numbers of lines to be deleted.
|
|
|
|
- std::set<unsigned> DeletedLines;
|
|
|
|
};
|
|
};
|
|
|
|
|
|
struct IncludeDirective {
|
|
struct IncludeDirective {
|