clang API Documentation

Classes | Namespaces | Defines | Functions
Format.cpp File Reference

This file implements functions declared in Format.h. This will be split into separate files as we go. More...

#include "ContinuationIndenter.h"
#include "TokenAnnotator.h"
#include "UnwrappedLineParser.h"
#include "WhitespaceManager.h"
#include "clang/Basic/Diagnostic.h"
#include "clang/Basic/DiagnosticOptions.h"
#include "clang/Basic/SourceManager.h"
#include "clang/Format/Format.h"
#include "clang/Lex/Lexer.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/Support/Allocator.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/YAMLTraits.h"
#include <queue>
#include <string>
Include dependency graph for Format.cpp:

Go to the source code of this file.

Classes

struct  llvm::yaml::ScalarEnumerationTraits< FormatStyle::LanguageKind >
struct  llvm::yaml::ScalarEnumerationTraits< FormatStyle::LanguageStandard >
struct  llvm::yaml::ScalarEnumerationTraits< FormatStyle::UseTabStyle >
struct  llvm::yaml::ScalarEnumerationTraits< FormatStyle::ShortFunctionStyle >
struct  llvm::yaml::ScalarEnumerationTraits< FormatStyle::BinaryOperatorStyle >
struct  llvm::yaml::ScalarEnumerationTraits< FormatStyle::BraceBreakingStyle >
struct  llvm::yaml::ScalarEnumerationTraits< FormatStyle::NamespaceIndentationKind >
struct  llvm::yaml::ScalarEnumerationTraits< FormatStyle::PointerAlignmentStyle >
struct  llvm::yaml::ScalarEnumerationTraits< FormatStyle::SpaceBeforeParensOptions >
struct  llvm::yaml::MappingTraits< FormatStyle >
struct  llvm::yaml::DocumentListTraits< std::vector< FormatStyle > >

Namespaces

namespace  llvm
namespace  llvm::yaml
namespace  clang
namespace  clang::format

Defines

#define DEBUG_TYPE   "format-formatter"

Functions

const std::error_category & clang::format::getParseCategory ()
std::error_code clang::format::make_error_code (ParseError e)
FormatStyle clang::format::getLLVMStyle ()
 Returns a format style complying with the LLVM coding standards: http://llvm.org/docs/CodingStandards.html.
FormatStyle clang::format::getGoogleStyle (FormatStyle::LanguageKind Language)
 Returns a format style complying with one of Google's style guides: http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml. http://google-styleguide.googlecode.com/svn/trunk/javascriptguide.xml. https://developers.google.com/protocol-buffers/docs/style.
FormatStyle clang::format::getChromiumStyle (FormatStyle::LanguageKind Language)
 Returns a format style complying with Chromium's style guide: http://www.chromium.org/developers/coding-style.
FormatStyle clang::format::getMozillaStyle ()
 Returns a format style complying with Mozilla's style guide: https://developer.mozilla.org/en-US/docs/Developer_Guide/Coding_Style.
FormatStyle clang::format::getWebKitStyle ()
 Returns a format style complying with Webkit's style guide: http://www.webkit.org/coding/coding-style.html.
FormatStyle clang::format::getGNUStyle ()
 Returns a format style complying with GNU Coding Standards: http://www.gnu.org/prep/standards/standards.html.
FormatStyle clang::format::getNoStyle ()
 Returns style indicating formatting should be not applied at all.
bool clang::format::getPredefinedStyle (StringRef Name, FormatStyle::LanguageKind Language, FormatStyle *Style)
 Gets a predefined style for the specified language by name.
std::error_code clang::format::parseConfiguration (StringRef Text, FormatStyle *Style)
 Parse configuration from YAML-formatted text.
std::string clang::format::configurationAsText (const FormatStyle &Style)
 Gets configuration in a YAML string.
tooling::Replacements clang::format::reformat (const FormatStyle &Style, Lexer &Lex, SourceManager &SourceMgr, ArrayRef< CharSourceRange > Ranges)
 Reformats the given Ranges in the token stream coming out of Lex.
tooling::Replacements clang::format::reformat (const FormatStyle &Style, SourceManager &SourceMgr, FileID ID, ArrayRef< CharSourceRange > Ranges)
 Reformats the given Ranges in the file ID.
tooling::Replacements clang::format::reformat (const FormatStyle &Style, StringRef Code, ArrayRef< tooling::Range > Ranges, StringRef FileName="<stdin>")
 Reformats the given Ranges in Code.
LangOptions clang::format::getFormattingLangOpts (const FormatStyle &Style=getLLVMStyle())
 Returns the LangOpts that the formatter expects you to set.
static FormatStyle::LanguageKind clang::format::getLanguageByFileName (StringRef FileName)
FormatStyle clang::format::getStyle (StringRef StyleName, StringRef FileName, StringRef FallbackStyle)
 Construct a FormatStyle based on StyleName.

Detailed Description

This file implements functions declared in Format.h. This will be split into separate files as we go.

Definition in file Format.cpp.


Define Documentation

#define DEBUG_TYPE   "format-formatter"

Definition at line 33 of file Format.cpp.


Variable Documentation

llvm::SpecificBumpPtrAllocator<FormatToken> Allocator

Definition at line 2079 of file Format.cpp.

Definition at line 1739 of file Format.cpp.

SmallVector<IdentifierInfo *, 8> ForEachMacros

Definition at line 1741 of file Format.cpp.

Definition at line 1743 of file Format.cpp.

FormatToken* FormatTok

Definition at line 1725 of file Format.cpp.

Definition at line 1727 of file Format.cpp.

FileID ID

Definition at line 1732 of file Format.cpp.

IdentifierTable IdentTable

Definition at line 1734 of file Format.cpp.

ContinuationIndenter* Indenter

Definition at line 603 of file Format.cpp.

Definition at line 1726 of file Format.cpp.

LineJoiner Joiner

Definition at line 1331 of file Format.cpp.

AdditionalKeywords Keywords

Definition at line 1735 of file Format.cpp.

std::unique_ptr<Lexer> Lex

Definition at line 1730 of file Format.cpp.

Referenced by clang::Lexer::LexFromRawLexer().

Definition at line 1030 of file Format.cpp.

Referenced by clang::format::CommaSeparatedList::formatAfterToken().

std::map<std::pair<const SmallVectorImpl<AnnotatedLine *> *, unsigned>, unsigned> PenaltyCache

Definition at line 1339 of file Format.cpp.

StateNode* Previous
SmallVector<CharSourceRange, 8> Ranges
SourceManager& SourceMgr
LineState State

Definition at line 1029 of file Format.cpp.

Referenced by clang::ento::CheckerContext::addTransition(), assumeCollectionNonEmpty(), clang::ento::ExprEngine::bindReturnValue(), checkCollectionNonNil(), clang::ento::CheckerDocumentation::checkConstPointerEscape(), checkElementNonNil(), checkForFunctionCall(), clang::ento::CheckerDocumentation::checkPointerEscape(), clang::ento::CheckerDocumentation::checkRegionChanges(), clang::MaterializeTemporaryExpr::children(), clang::ento::CallEvent::cloneWithState(), clang::CodeGen::CodeGenFunction::EmitCondBrHints(), clang::ento::CheckerDocumentation::evalAssume(), clang::ento::CheckerContext::generateSink(), getArgumentValueString(), getAsPointeeSymbol(), clang::consumed::PropagationInfo::getAsState(), clang::ento::CheckerContext::getCalleeDecl(), clang::CallEventManager::getCaller(), clang::CallEventManager::getCXXAllocatorCall(), clang::CallEventManager::getCXXConstructorCall(), clang::CallEventManager::getCXXDestructorCall(), clang::MaterializeTemporaryExpr::getExtendingDecl(), clang::format::ContinuationIndenter::getInitialState(), clang::ento::ProgramStateManager::getInitialState(), clang::MaterializeTemporaryExpr::getManglingNumber(), clang::ento::StackHintGeneratorForSymbol::getMessage(), clang::CallEventManager::getObjCMethodCall(), clang::CallEventManager::getSimpleCall(), clang::ento::CallEvent::getState(), clang::consumed::PropagationInfo::getState(), clang::MaterializeTemporaryExpr::getTemporary(), handleLoopHintAttr(), clang::ento::ExprEngine::notifyCheckersOfPointerEscape(), clang::ento::ExprEngine::processPointerEscapedOnBind(), clang::ento::ExprEngine::ProcessTemporaryDtor(), recordFixedType(), REGISTER_TRAIT_WITH_PROGRAMSTATE(), clang::ento::CheckerManager::runCheckersForPointerEscape(), clang::MaterializeTemporaryExpr::setExtendingDecl(), clang::consumed::ConsumedStateMap::setState(), clang::consumed::setStateForVarOrTmp(), clang::serialization::ModuleManager::visit(), clang::ento::ExprEngine::VisitBlockExpr(), clang::ento::ExprEngine::VisitCompoundLiteralExpr(), clang::ento::UndefOrNullArgVisitor::VisitNode(), and clang::ento::ExprEngine::VisitObjCMessage().

SmallVector<FormatToken *, 16> Tokens

Definition at line 1729 of file Format.cpp.

SmallVector<SmallVector<UnwrappedLine, 16>, 2> UnwrappedLines

Definition at line 2076 of file Format.cpp.

WhitespaceManager Whitespaces

Definition at line 1329 of file Format.cpp.