aboutsummaryrefslogtreecommitdiff
path: root/clang-format
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2013-01-15 18:56:19 +0000
committerDaniel Jasper <djasper@google.com>2013-01-15 18:56:19 +0000
commitba39ad26bb7059d01fd11c09d0201201695cd1d3 (patch)
tree1599be4b6c19a4537c8b554bac7ddc00ccd7d5b9 /clang-format
parentb978eb814cf956ae2dceaeeeaba4e49312416af9 (diff)
Add temporary option to invert the */& binding in a specific style.
This is temporarily necessary until styles are configurable through files as it seems to be a contentious issue. git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@172546 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'clang-format')
-rw-r--r--clang-format/ClangFormat.cpp25
1 files changed, 17 insertions, 8 deletions
diff --git a/clang-format/ClangFormat.cpp b/clang-format/ClangFormat.cpp
index 74bcc266..16bfbe09 100644
--- a/clang-format/ClangFormat.cpp
+++ b/clang-format/ClangFormat.cpp
@@ -39,6 +39,11 @@ static cl::opt<std::string> Style(
static cl::opt<bool> Inplace("i",
cl::desc("Inplace edit <file>, if specified."));
+// FIXME: Remove this when styles are configurable through files.
+static cl::opt<bool> InvertPointerBinding(
+ "invert-pointer-binding", cl::desc("Inverts the side to which */& bind"),
+ cl::init(false));
+
static cl::opt<std::string> FileName(cl::Positional, cl::desc("[<file>]"),
cl::init("-"));
@@ -54,12 +59,17 @@ static FileID createInMemoryFile(StringRef FileName, const MemoryBuffer *Source,
return Sources.createFileID(Entry, SourceLocation(), SrcMgr::C_User);
}
-static FormatStyle getStyle(StringRef name) {
- if (name == "LLVM")
- return getLLVMStyle();
- if (name == "Chromium")
- return getChromiumStyle();
- return getGoogleStyle();
+static FormatStyle getStyle() {
+ FormatStyle TheStyle = getGoogleStyle();
+ if (Style == "LLVM")
+ TheStyle = getLLVMStyle();
+ if (Style == "Chromium")
+ TheStyle = getChromiumStyle();
+ if (InvertPointerBinding) {
+ TheStyle.PointerAndReferenceBindToType =
+ !TheStyle.PointerAndReferenceBindToType;
+ }
+ return TheStyle;
}
static void format() {
@@ -82,8 +92,7 @@ static void format() {
End = Start.getLocWithOffset(Length);
std::vector<CharSourceRange> Ranges(
1, CharSourceRange::getCharRange(Start, End));
- tooling::Replacements Replaces = reformat(getStyle(Style), Lex, Sources,
- Ranges);
+ tooling::Replacements Replaces = reformat(getStyle(), Lex, Sources, Ranges);
Rewriter Rewrite(Sources, LangOptions());
tooling::applyAllReplacements(Replaces, Rewrite);
if (Inplace) {