diff options
Diffstat (limited to 'include/clang/Format/Format.h')
-rw-r--r-- | include/clang/Format/Format.h | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/include/clang/Format/Format.h b/include/clang/Format/Format.h new file mode 100644 index 0000000000..c2deccfda2 --- /dev/null +++ b/include/clang/Format/Format.h @@ -0,0 +1,75 @@ +//===--- Format.h - Format C++ code -----------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +/// +/// \file +/// Various functions to configurably format source code. +/// +/// This is EXPERIMENTAL code under heavy development. It is not in a state yet, +/// where it can be used to format real code. +/// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_CLANG_FORMAT_FORMAT_H_ +#define LLVM_CLANG_FORMAT_FORMAT_H + +#include "clang/Frontend/FrontendAction.h" +#include "clang/Tooling/Refactoring.h" + +namespace clang { + +class Lexer; +class SourceManager; + +namespace format { + +/// \brief The \c FormatStyle is used to configure the formatting to follow +/// specific guidelines. +struct FormatStyle { + /// \brief The column limit. + unsigned ColumnLimit; + + /// \brief The maximum number of consecutive empty lines to keep. + unsigned MaxEmptyLinesToKeep; + + /// \brief Set whether & and * bind to the type as opposed to the variable. + bool PointerAndReferenceBindToType; + + /// \brief The extra indent or outdent of access modifiers (e.g.: public:). + int AccessModifierOffset; + + /// \brief Split two consecutive closing '>' by a space, i.e. use + /// A<A<int> > instead of A<A<int>>. + bool SplitTemplateClosingGreater; +}; + +/// \brief Returns a format style complying with the LLVM coding standards: +/// http://llvm.org/docs/CodingStandards.html. +FormatStyle getLLVMStyle(); + +/// \brief Returns a format style complying with Google's C++ style guide: +/// http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml. +FormatStyle getGoogleStyle(); + +/// \brief Reformats the given \p Ranges in the token stream coming out of +/// \c Lex. +/// +/// Each range is extended on either end to its next bigger logic unit, i.e. +/// everything that might influence its formatting or might be influenced by its +/// formatting. +/// +/// Returns the \c Replacements necessary to make all \p Ranges comply with +/// \p Style. +tooling::Replacements reformat(const FormatStyle &Style, Lexer &Lex, + SourceManager &SourceMgr, + std::vector<CharSourceRange> Ranges); + +} // end namespace format +} // end namespace clang + +#endif // LLVM_CLANG_FORMAT_FORMAT_H |