Implements UseTab for clang-format.
This is required for kernel linux kernel style formatting.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181693 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Format/WhitespaceManager.cpp b/lib/Format/WhitespaceManager.cpp
index a75c592..21e38b1 100644
--- a/lib/Format/WhitespaceManager.cpp
+++ b/lib/Format/WhitespaceManager.cpp
@@ -122,7 +122,7 @@
std::string WhitespaceManager::getNewLineText(unsigned NewLines,
unsigned Spaces) {
- return std::string(NewLines, '\n') + std::string(Spaces, ' ');
+ return std::string(NewLines, '\n') + getIndentText(Spaces);
}
std::string WhitespaceManager::getNewLineText(unsigned NewLines,
@@ -139,7 +139,15 @@
Offset = 0;
}
}
- return NewLineText + std::string(Spaces, ' ');
+ return NewLineText + getIndentText(Spaces);
+}
+
+std::string WhitespaceManager::getIndentText(unsigned Spaces) {
+ if (!Style.UseTab) {
+ return std::string(Spaces, ' ');
+ }
+ return std::string(Spaces / Style.IndentWidth, '\t') +
+ std::string(Spaces % Style.IndentWidth, ' ');
}
void WhitespaceManager::alignComments() {