clang
6.0.0
|
This file implements functions declared in Format.h. More...
#include "clang/Format/Format.h"
#include "AffectedRangeManager.h"
#include "ContinuationIndenter.h"
#include "FormatInternal.h"
#include "FormatTokenLexer.h"
#include "NamespaceEndCommentsFixer.h"
#include "SortJavaScriptImports.h"
#include "TokenAnalyzer.h"
#include "TokenAnnotator.h"
#include "UnwrappedLineFormatter.h"
#include "UnwrappedLineParser.h"
#include "UsingDeclarationsSorter.h"
#include "WhitespaceManager.h"
#include "clang/Basic/Diagnostic.h"
#include "clang/Basic/DiagnosticOptions.h"
#include "clang/Basic/SourceManager.h"
#include "clang/Basic/VirtualFileSystem.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/Regex.h"
#include "llvm/Support/YAMLTraits.h"
#include <algorithm>
#include <memory>
#include <string>
Go to the source code of this file.
Namespaces | |
llvm | |
DominatorTree GraphTraits specialization so the DominatorTree can be iterable by generic graph iterators. | |
llvm::yaml | |
clang | |
Dataflow Directional Tag Classes. | |
clang::format | |
clang::format::internal | |
Macros | |
#define | DEBUG_TYPE "format-formatter" |
Functions | |
const std::error_category & | clang::format::getParseCategory () |
std::error_code | clang::format::make_error_code (ParseError e) |
llvm::Error | clang::format::make_string_error (const llvm::Twine &Message) |
static FormatStyle | clang::format::expandPresets (const FormatStyle &Style) |
FormatStyle | clang::format::getLLVMStyle () |
Returns a format style complying with the LLVM coding standards: http://llvm.org/docs/CodingStandards.html. More... | |
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. More... | |
FormatStyle | clang::format::getChromiumStyle (FormatStyle::LanguageKind Language) |
Returns a format style complying with Chromium's style guide: http://www.chromium.org/developers/coding-style. More... | |
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. More... | |
FormatStyle | clang::format::getWebKitStyle () |
Returns a format style complying with Webkit's style guide: http://www.webkit.org/coding/coding-style.html. More... | |
FormatStyle | clang::format::getGNUStyle () |
Returns a format style complying with GNU Coding Standards: http://www.gnu.org/prep/standards/standards.html. More... | |
FormatStyle | clang::format::getNoStyle () |
Returns style indicating formatting should be not applied at all. More... | |
bool | clang::format::getPredefinedStyle (StringRef Name, FormatStyle::LanguageKind Language, FormatStyle *Style) |
Gets a predefined style for the specified language by name. More... | |
std::error_code | clang::format::parseConfiguration (StringRef Text, FormatStyle *Style) |
Parse configuration from YAML-formatted text. More... | |
std::string | clang::format::configurationAsText (const FormatStyle &Style) |
Gets configuration in a YAML string. More... | |
static bool | clang::format::affectsRange (ArrayRef< tooling::Range > Ranges, unsigned Start, unsigned End) |
static std::pair< unsigned, unsigned > | clang::format::FindCursorIndex (const SmallVectorImpl< IncludeDirective > &Includes, const SmallVectorImpl< unsigned > &Indices, unsigned Cursor) |
static void | clang::format::sortCppIncludes (const FormatStyle &Style, const SmallVectorImpl< IncludeDirective > &Includes, ArrayRef< tooling::Range > Ranges, StringRef FileName, tooling::Replacements &Replaces, unsigned *Cursor) |
tooling::Replacements | clang::format::sortCppIncludes (const FormatStyle &Style, StringRef Code, ArrayRef< tooling::Range > Ranges, StringRef FileName, tooling::Replacements &Replaces, unsigned *Cursor) |
bool | clang::format::isMpegTS (StringRef Code) |
bool | clang::format::isLikelyXml (StringRef Code) |
tooling::Replacements | clang::format::sortIncludes (const FormatStyle &Style, StringRef Code, ArrayRef< tooling::Range > Ranges, StringRef FileName, unsigned *Cursor=nullptr) |
Returns the replacements necessary to sort all #include blocks that are affected by Ranges . More... | |
template<typename T > | |
static llvm::Expected< tooling::Replacements > | clang::format::processReplacements (T ProcessFunc, StringRef Code, const tooling::Replacements &Replaces, const FormatStyle &Style) |
llvm::Expected< tooling::Replacements > | clang::format::formatReplacements (StringRef Code, const tooling::Replacements &Replaces, const FormatStyle &Style) |
Returns the replacements corresponding to applying and formatting Replaces on success; otheriwse, return an llvm::Error carrying llvm::StringError. More... | |
llvm::Expected< tooling::Replacements > | clang::format::cleanupAroundReplacements (StringRef Code, const tooling::Replacements &Replaces, const FormatStyle &Style) |
Returns the replacements corresponding to applying Replaces and cleaning up the code after that on success; otherwise, return an llvm::Error carrying llvm::StringError. More... | |
std::pair< tooling::Replacements, unsigned > | clang::format::internal::reformat (const FormatStyle &Style, StringRef Code, ArrayRef< tooling::Range > Ranges, unsigned FirstStartColumn, unsigned NextStartColumn, unsigned LastStartColumn, StringRef FileName, FormattingAttemptStatus *Status) |
Reformats the given Ranges in the code fragment Code . More... | |
tooling::Replacements | clang::format::reformat (const FormatStyle &Style, StringRef Code, ArrayRef< tooling::Range > Ranges, StringRef FileName="<stdin>", FormattingAttemptStatus *Status=nullptr) |
Reformats the given Ranges in Code . More... | |
tooling::Replacements | clang::format::cleanup (const FormatStyle &Style, StringRef Code, ArrayRef< tooling::Range > Ranges, StringRef FileName="<stdin>") |
Clean up any erroneous/redundant code in the given Ranges in Code . More... | |
tooling::Replacements | clang::format::reformat (const FormatStyle &Style, StringRef Code, ArrayRef< tooling::Range > Ranges, StringRef FileName, bool *IncompleteFormat) |
Same as above, except if IncompleteFormat is non-null, its value will be set to true if any of the affected ranges were not formatted due to a non-recoverable syntax error. More... | |
tooling::Replacements | clang::format::fixNamespaceEndComments (const FormatStyle &Style, StringRef Code, ArrayRef< tooling::Range > Ranges, StringRef FileName="<stdin>") |
Fix namespace end comments in the given Ranges in Code . More... | |
tooling::Replacements | clang::format::sortUsingDeclarations (const FormatStyle &Style, StringRef Code, ArrayRef< tooling::Range > Ranges, StringRef FileName="<stdin>") |
Sort consecutive using declarations in the given Ranges in Code . More... | |
LangOptions | clang::format::getFormattingLangOpts (const FormatStyle &Style=getLLVMStyle()) |
Returns the LangOpts that the formatter expects you to set. More... | |
static FormatStyle::LanguageKind | clang::format::getLanguageByFileName (StringRef FileName) |
llvm::Expected< FormatStyle > | clang::format::getStyle (StringRef StyleName, StringRef FileName, StringRef FallbackStyle, StringRef Code="", vfs::FileSystem *FS=nullptr) |
Construct a FormatStyle based on StyleName . More... | |
This file implements functions declared in Format.h.
This will be split into separate files as we go.
Definition in file Format.cpp.
#define DEBUG_TYPE "format-formatter" |
Definition at line 44 of file Format.cpp.
int Category |
Definition at line 1348 of file Format.cpp.
Referenced by clang::Sema::ActOnStartCategoryInterface(), clang::Sema::CodeCompleteObjCPropertyGetter(), clang::Sema::CodeCompleteObjCPropertySetter(), clang::tooling::CommonOptionsParser::CommonOptionsParser(), clang::cross_tu::IndexError::convertToErrorCode(), clang::tooling::CommonOptionsParser::create(), clang::tooling::ArgumentsAdjustingCompilations::getAllCompileCommands(), clang::ento::PathDiagnostic::getCategory(), hasWrittenStorageAttribute(), clang::CodeGen::CodeGenModule::isInSanitizerBlacklist(), clang::cross_tu::IndexError::log(), LookupMemberExpr(), clang::CodeGen::CodeGenModule::setFunctionLinkage(), clang::InitializationSequence::steps(), clang::ASTNodeImporter::VisitObjCCategoryImplDecl(), and clang::tooling::ToolExecutorPlugin::~ToolExecutorPlugin().
StringRef Filename |
Definition at line 1345 of file Format.cpp.
Referenced by adjustFilenameForRelocatableAST(), clang::PrecompiledPreamble::Build(), clang::Preprocessor::checkModuleIsAvailable(), clang::ento::CreateAnalysisConsumer(), clang::FixItAction::CreateASTConsumer(), CreateSLocExpansionAbbrev(), CreateUbiViz(), DetectEOL(), clang::ModuleMap::diagnoseHeaderInclusion(), clang::CodeGen::CodeGenFunction::EmitCheckSourceLocation(), clang::TextDiagnostic::emitCodeContext(), clang::BackendConsumer::EmitOptimizationMessage(), EnableCodeCompletion(), EvaluateHasIncludeCommon(), clang::FixItOptions::FixItOptions(), clang::FileManager::getBufferForFile(), clang::DependencyCollector::getDependencies(), clang::PresumedLoc::getFilename(), clang::CompilerInstance::getFrontendTimer(), clang::SourceManager::getPresumedLoc(), getPrivateModuleMap(), clang::Preprocessor::HandlePragmaDependency(), clang::HeaderMapImpl::HeaderMapImpl(), clang::ASTReader::ImportedSubmodule::ImportedSubmodule(), clang::Rewriter::IncreaseIndentation(), clang::ModuleDependencyCollector::insertSeen(), isBuiltinFile(), isCommandLineFile(), clang::DirectoryLookup::isIndexHeaderMap(), isNoCommonDefault(), isSpecialFilename(), clang::HeaderSearch::LookupFile(), MakeCLOutputFilename(), needModuleLookup(), clang::TextDiagnostic::printDiagnosticMessage(), PrintFilename(), clang::serialization::reader::HeaderFileInfoTrait::ReadData(), clang::ASTReader::ReadPath(), clang::Preprocessor::setCounterValue(), clang::HeaderSearch::SetExternalSource(), clang::ChainedASTReaderListener::takeSecond(), and clang::BackendConsumer::UnsupportedDiagHandler().
unsigned Offset |
Definition at line 1347 of file Format.cpp.
const SourceManager& SM |
Definition at line 1337 of file Format.cpp.
Referenced by clang::CodeGen::CodeGenModule::AddDeferredUnusedCoverageMapping(), clang::ASTUnit::addFileLevelDecl(), addFixitForObjCARCConversion(), clang::arcmt::trans::MigrationContext::addPropertyAttribute(), clang::GCCAsmStmt::AnalyzeAsmString(), clang::tooling::Replacement::apply(), applyEditsToTemp(), clang::CodeGen::CodeGenPGO::assignRegionCounters(), clang::ento::ProgramState::assumeInBound(), clang::AttachHeaderIncludeGen(), clang::TokenConcatenation::AvoidConcat(), clang::CFGStmtMap::Build(), clang::ObjCMethodCall::canBeOverridenInSubclass(), checkAndSanitizeDiags(), compare(), comparePiece(), clang::tooling::ExtractionSemicolonPolicy::compute(), clang::ento::PathDiagnosticCallPiece::construct(), clang::StmtSequence::contains(), clang::SrcMgr::ContentCache::ContentCache(), clang::Lexer::Create_PragmaLexer(), createAttributeInsertion(), clang::ento::PathDiagnosticLocation::createBegin(), clang::ento::PathDiagnosticLocation::createConditionalColonLoc(), clang::ento::PathDiagnosticLocation::createMemberLoc(), clang::ento::PathDiagnosticLocation::createOperatorLoc(), clang::Sema::DiagnoseAlwaysNonNullPointer(), clang::DoRewriteTest(), clang::Decl::dump(), clang::CodeGen::CodeGenModule::EmitAnnotationLineNo(), clang::CodeGen::CodeGenModule::EmitAnnotationUnit(), clang::TextDiagnostic::emitCodeContext(), clang::CodeGen::CoverageMappingGen::emitCounterMapping(), clang::CodeGen::CoverageMappingGen::emitEmptyMapping(), clang::markup::EmitLocation(), clang::DiagnosticRenderer::emitStoredDiagnostic(), clang::arcmt::CapturedDiagList::end(), clang::DiagnosticRenderer::endDiagnostic(), clang::CodeGenAction::ExecuteAction(), clang::DumpRawTokensAction::ExecuteAction(), clang::PrintPreprocessedAction::ExecuteAction(), clang::sema::SemaPPCallbacks::FileChanged(), clang::arcmt::trans::findSemiAfterLocation(), clang::tooling::formatAndApplyAllReplacements(), GenerateAlternateExtensivePathDiagnostic(), clang::index::generateUSRForMacro(), GetAllocationSite(), clang::TypedefNameDecl::getAnonDeclWithTypedefName(), clang::Lexer::getAsCharRange(), getAsmSrcLocInfo(), getAsPointeeSymbol(), clang::ento::ModelInjector::getBody(), clang::ento::PathDiagnosticCallPiece::getCallee(), clang::ASTWriter::getDeclID(), clang::ento::BugReport::getExtraText(), GetFirstChar(), GetHashOfContent(), clang::ASTUnit::getLocation(), getLocationForCaller(), clang::ento::ProgramState::getLValue(), clang::MacroDirective::getMacroInfo(), clang::ento::PathDiagnosticLocation::getManager(), GetMappedTokenLoc(), clang::ast_type_traits::DynTypedNode::getMemoizationData(), clang::Preprocessor::getModuleHeaderToIncludeForDiagnostics(), clang::SourceManager::getPresumedColumnNumber(), clang::FunctionDecl::getReturnTypeSourceRange(), clang::Stmt::getStmtClass(), getStrlenExprArg(), getTargetEntryUniqueInfo(), clang::index::getUSRSpacePrefix(), clang::VerifyDiagnosticConsumer::HandleComment(), clang::LogDiagnosticPrinter::HandleDiagnostic(), hasSuperInitCall(), clang::html::HighlightMacros(), clang::index::IndexingContext::importedModule(), clang::VisibleDeclConsumer::includeHiddenDecls(), clang::TokenLexer::Init(), clang::PreprocessingRecord::isEntityInFileID(), llvm::DenseMapInfo< EditEntry >::isEqual(), isGeneralizedObjectRef(), clang::CodeGen::CodeGenModule::isInSanitizerBlacklist(), clang::ento::CallEvent::isInSystemHeader(), clang::SourceLocation::isPairOfFileLocations(), clang::TokenLexer::isParsingPreprocessorDirective(), IsStringPrefix(), clang::TokenLexer::Lex(), LexRawTokensFromMainFile(), LocPropertyAttribute(), makeStandaloneDiagnostic(), clang::Parser::ParseConstraintExpression(), clang::PrettyStackTraceDecl::print(), clang::TextDiagnostic::printDiagnosticMessage(), pwrite32le(), ReadLineMarkerFlags(), clang::edit::Commit::replaceText(), ReportPiece(), clang::RewriteMacrosInInput(), clang::arcmt::trans::MigrationContext::rewritePropertyAttribute(), SelectDigraphErrorMessage(), clang::ento::PathDiagnosticCallPiece::setCallee(), clang::CodeGen::CGDebugInfo::setLocation(), clang::Rewriter::setSourceMgr(), clang::StringLiteral::setStrTokenLoc(), shouldReportOccurrenceForSystemDeclOnlyMode(), clang::CoverageSourceInfo::SourceRangeSkipped(), sumOffsets(), clang::html::SyntaxHighlight(), updateConsecutiveMacroArgTokens(), and clang::VerifyDiagnosticConsumer::~VerifyDiagnosticConsumer().
StringRef Text |
Definition at line 1346 of file Format.cpp.
Referenced by clang::CodeCompletionString::Chunk::Chunk(), clang::format::encoding::columnWidthWithTabs(), clang::comments::Sema::copyArray(), clang::VerifyDiagnosticConsumer::Directive::create(), clang::arcmt::MigrateSourceAction::CreateASTConsumer(), clang::format::FindCursorIndex(), clang::format::WhitespaceManager::generateReplacements(), clang::CodeCompletionBuilder::getCodeCompletionTUInfo(), clang::comments::TextComment::getText(), clang::comments::VerbatimBlockLineComment::getText(), clang::comments::VerbatimLineComment::getText(), clang::format::WhitespaceManager::Change::indentAndNestingLevel(), clang::tooling::AtomicChange::insert(), clang::comments::Parser::parseVerbatimLine(), shouldWarnOnMacroDef(), and shouldWarnOnMacroUndef().