aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/Format/Format.cpp6
-rw-r--r--unittests/Format/FormatTest.cpp9
2 files changed, 13 insertions, 2 deletions
diff --git a/lib/Format/Format.cpp b/lib/Format/Format.cpp
index 1aa7acf3de..120b54d831 100644
--- a/lib/Format/Format.cpp
+++ b/lib/Format/Format.cpp
@@ -928,6 +928,10 @@ private:
bool spaceRequiredBetween(const AnnotatedToken &Left,
const AnnotatedToken &Right) {
+ if (Right.is(tok::hashhash))
+ return Left.is(tok::hash);
+ if (Left.is(tok::hashhash) || Left.is(tok::hash))
+ return Right.is(tok::hash);
if (Right.is(tok::r_paren) || Right.is(tok::semi) || Right.is(tok::comma))
return false;
if (Left.is(tok::kw_template) && Right.is(tok::less))
@@ -962,8 +966,6 @@ private:
return true;
if (Left.is(tok::l_paren))
return false;
- if (Left.is(tok::hash))
- return false;
if (Right.is(tok::l_paren)) {
return Left.is(tok::kw_if) || Left.is(tok::kw_for) ||
Left.is(tok::kw_while) || Left.is(tok::kw_switch) ||
diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp
index c3f364db39..677b0e99bd 100644
--- a/unittests/Format/FormatTest.cpp
+++ b/unittests/Format/FormatTest.cpp
@@ -551,6 +551,15 @@ TEST_F(FormatTest, HashInMacroDefinition) {
" { \\\n"
" f(#c);\\\n"
" }", getLLVMStyleWithColumns(11));
+
+ verifyFormat("#define A(X) \\\n"
+ " void function##X()", getLLVMStyleWithColumns(22));
+
+ verifyFormat("#define A(a, b, c) \\\n"
+ " void a##b##c()", getLLVMStyleWithColumns(22));
+
+ verifyFormat("#define A \\\n"
+ " void # ## #", getLLVMStyleWithColumns(22));
}
TEST_F(FormatTest, IndentPreprocessorDirectivesAtZero) {