summaryrefslogtreecommitdiffstats
path: root/clang/lib/Format/UnwrappedLineParser.h
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/Format/UnwrappedLineParser.h')
-rw-r--r--clang/lib/Format/UnwrappedLineParser.h10
1 files changed, 8 insertions, 2 deletions
diff --git a/clang/lib/Format/UnwrappedLineParser.h b/clang/lib/Format/UnwrappedLineParser.h
index f48594d592d..1ab1ca21dc7 100644
--- a/clang/lib/Format/UnwrappedLineParser.h
+++ b/clang/lib/Format/UnwrappedLineParser.h
@@ -84,7 +84,7 @@ struct FormatToken {
/// \c UnwrappedLineFormatter. The key property is that changing the formatting
/// within an unwrapped line does not affect any other unwrapped lines.
struct UnwrappedLine {
- UnwrappedLine() : Level(0), InPPDirective(false) {
+ UnwrappedLine() : Level(0), InPPDirective(false), MustBeDeclaration(false) {
}
// FIXME: Don't use std::list here.
@@ -96,6 +96,8 @@ struct UnwrappedLine {
/// \brief Whether this \c UnwrappedLine is part of a preprocessor directive.
bool InPPDirective;
+
+ bool MustBeDeclaration;
};
class UnwrappedLineConsumer {
@@ -124,7 +126,7 @@ public:
private:
bool parseFile();
bool parseLevel(bool HasOpeningBrace);
- bool parseBlock(unsigned AddLevels = 1);
+ bool parseBlock(bool MustBeDeclaration, unsigned AddLevels = 1);
void parsePPDirective();
void parsePPDefine();
void parsePPUnknown();
@@ -180,6 +182,10 @@ private:
// \c &PreprocessorDirectives.
std::vector<UnwrappedLine> *CurrentLines;
+ // We store for each line whether it must be a declaration depending on
+ // whether we are in a compound statement or not.
+ std::vector<bool> DeclarationScopeStack;
+
clang::DiagnosticsEngine &Diag;
const FormatStyle &Style;
FormatTokenSource *Tokens;
OpenPOWER on IntegriCloud