clang 20.0.0git
|
This file implements functions declared in Format.h. More...
#include "clang/Format/Format.h"
#include "DefinitionBlockSeparator.h"
#include "IntegerLiteralSeparatorFixer.h"
#include "NamespaceEndCommentsFixer.h"
#include "ObjCPropertyAttributeOrderFixer.h"
#include "QualifierAlignmentFixer.h"
#include "SortJavaScriptImports.h"
#include "UnwrappedLineFormatter.h"
#include "UsingDeclarationsSorter.h"
#include "clang/Tooling/Inclusions/HeaderIncludes.h"
#include "llvm/ADT/Sequence.h"
Go to the source code of this file.
Namespaces | |
namespace | llvm |
Diagnostic wrappers for TextAPI types for error reporting. | |
namespace | llvm::yaml |
namespace | clang |
The JSON file list parser is used to communicate input to InstallAPI. | |
namespace | clang::format |
namespace | 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 Twine &Message) |
static void | clang::format::expandPresetsBraceWrapping (FormatStyle &Expanded) |
static void | clang::format::expandPresetsSpaceBeforeParens (FormatStyle &Expanded) |
static void | clang::format::expandPresetsSpacesInParens (FormatStyle &Expanded) |
FormatStyle | clang::format::getLLVMStyle (FormatStyle::LanguageKind Language=FormatStyle::LanguageKind::LK_Cpp) |
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. | |
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://firefox-source-docs.mozilla.org/code-quality/coding-style/index.html. | |
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::getMicrosoftStyle (FormatStyle::LanguageKind Language) |
Returns a format style complying with Microsoft style guide: https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference?view=vs-2017. | |
FormatStyle | clang::format::getClangFormatStyle () |
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. | |
ParseError | clang::format::validateQualifierOrder (FormatStyle *Style) |
std::error_code | clang::format::parseConfiguration (llvm::MemoryBufferRef Config, FormatStyle *Style, bool AllowUnknownOptions=false, llvm::SourceMgr::DiagHandlerTy DiagHandler=nullptr, void *DiagHandlerCtx=nullptr) |
Parse configuration from YAML-formatted text. | |
std::string | clang::format::configurationAsText (const FormatStyle &Style) |
Gets configuration in a YAML string. | |
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) |
std::string | clang::format::replaceCRLF (const std::string &Code) |
static void | clang::format::sortCppIncludes (const FormatStyle &Style, const SmallVectorImpl< IncludeDirective > &Includes, ArrayRef< tooling::Range > Ranges, StringRef FileName, StringRef Code, 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) |
static unsigned | clang::format::findJavaImportGroup (const FormatStyle &Style, StringRef ImportIdentifier) |
static void | clang::format::sortJavaImports (const FormatStyle &Style, const SmallVectorImpl< JavaImportDirective > &Imports, ArrayRef< tooling::Range > Ranges, StringRef FileName, StringRef Code, tooling::Replacements &Replaces) |
tooling::Replacements | clang::format::sortJavaImports (const FormatStyle &Style, StringRef Code, ArrayRef< tooling::Range > Ranges, StringRef FileName, tooling::Replacements &Replaces) |
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 . | |
template<typename T > | |
static Expected< tooling::Replacements > | clang::format::processReplacements (T ProcessFunc, StringRef Code, const tooling::Replacements &Replaces, const FormatStyle &Style) |
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. | |
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. | |
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 . | |
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 . | |
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 . | |
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. | |
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 . | |
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 . | |
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::LanguageKind | clang::format::guessLanguage (StringRef FileName, StringRef Code) |
llvm::ErrorOr< std::unique_ptr< llvm::MemoryBuffer > > | clang::format::loadAndParseConfigFile (StringRef ConfigFile, llvm::vfs::FileSystem *FS, FormatStyle *Style, bool AllowUnknownOptions, llvm::SourceMgr::DiagHandlerTy DiagHandler) |
Expected< FormatStyle > | clang::format::getStyle (StringRef StyleName, StringRef FileName, StringRef FallbackStyle, StringRef Code="", llvm::vfs::FileSystem *FS=nullptr, bool AllowUnknownOptions=false, llvm::SourceMgr::DiagHandlerTy DiagHandler=nullptr) |
Construct a FormatStyle based on StyleName . | |
static bool | clang::format::isClangFormatOnOff (StringRef Comment, bool On) |
bool | clang::format::isClangFormatOn (StringRef Comment) |
bool | clang::format::isClangFormatOff (StringRef Comment) |
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 27 of file Format.cpp.
SmallVector<StringRef> AssociatedCommentLines |
Definition at line 3012 of file Format.cpp.
Referenced by clang::format::sortJavaImports().
int Category |
Definition at line 3004 of file Format.cpp.
Referenced by clang::SemaObjC::ActOnPropertyImplDecl(), AddObjCProperties(), clang::ento::BugType::BugType(), checkAtomicPropertyMismatch(), CheckForIncompatibleAttributes(), clang::SemaCodeCompletion::CodeCompleteObjCInterfaceCategory(), clang::SemaCodeCompletion::CodeCompleteObjCMethodDecl(), clang::SemaCodeCompletion::CodeCompleteObjCPropertyGetter(), clang::SemaCodeCompletion::CodeCompleteObjCPropertySetter(), CollectOverriddenMethodsRecurse(), clang::NoSanitizeList::containsFile(), clang::NoSanitizeList::containsGlobal(), clang::NoSanitizeList::containsLocation(), clang::NoSanitizeList::containsMainFile(), clang::NoSanitizeList::containsType(), clang::cross_tu::IndexError::convertToErrorCode(), clang::tooling::CommonOptionsParser::create(), clang::tooling::createExecutorFromCommandLineArgs(), clang::tooling::internal::createExecutorFromCommandLineArgsImpl(), clang::CodeGen::CGDebugInfo::CreateTrapFailureMessageFor(), clang::ento::BugReporter::EmitBasicReport(), FindImplementableMethods(), clang::ObjCMethodDecl::findPropertyDecl(), clang::ento::PathDiagnostic::getCategory(), clang::ento::BugType::getCategory(), clang::extractapi::DeclarationFragmentsBuilder::getFragmentsForObjCCategory(), hasWrittenStorageAttribute(), clang::tooling::HeaderIncludes::HeaderIncludes(), clang::CodeGen::CodeGenModule::imbueXRayAttrs(), clang::tooling::IncludeCategoryManager::IncludeCategoryManager(), clang::SanitizerSpecialCaseList::inSection(), clang::CodeGen::CodeGenModule::isInNoSanitizeList(), clang::isOpenMPExecutableDirective(), clang::isOpenMPInformationalDirective(), clang::cross_tu::IndexError::log(), LookupMemberExpr(), clang::Sema::ProcessAPINotes(), clang::ento::PathDiagnostic::Profile(), clang::XRayFunctionFilter::shouldImbueFunctionsInFile(), clang::XRayFunctionFilter::shouldImbueLocation(), clang::format::sortCppIncludes(), clang::JSONNodeDumper::Visit(), and clang::ASTNodeImporter::VisitObjCCategoryImplDecl().
StringRef Filename |
Definition at line 3001 of file Format.cpp.
Referenced by clang::InMemoryModuleCache::addBuiltPCM(), clang::DependencyCollector::addDependency(), clang::ModuleDependencyCollector::addFile(), clang::index::PathPool::addFilePath(), clang::InMemoryModuleCache::addPCM(), clang::Module::addTopHeaderFilename(), adjustFilenameForRelocatableAST(), clang::ast_matchers::AST_POLYMORPHIC_MATCHER_REGEX(), clang::FrontendAction::BeginSourceFile(), clang::PrecompiledPreamble::Build(), clang::ASTUnit::CodeComplete(), clang::SemaCodeCompletion::CodeCompleteIncludedFile(), clang::driver::tools::Clang::ConstructJob(), clang::CompilerInstance::createCodeCompletionConsumer(), clang::ModuleMap::diagnoseHeaderInclusion(), clang::ento::ExprEngine::DumpGraph(), clang::BackendConsumer::EmitOptimizationMessage(), EnableCodeCompletion(), EvaluateHasIncludeCommon(), fileNameToURI(), clang::InMemoryModuleCache::finalizePCM(), clang::tooling::dependencies::DependencyScanningFilesystemSharedCache::CacheShard::findEntryByFilename(), clang::tooling::dependencies::DependencyScanningFilesystemLocalCache::findEntryByFilename(), clang::installapi::findLibrary(), clang::tooling::dependencies::DependencyScanningFilesystemSharedCache::CacheShard::findRealPathByFilename(), clang::tooling::dependencies::DependencyScanningFilesystemLocalCache::findRealPathByFilename(), clang::SrcMgr::FileInfo::get(), clang::LineEntry::get(), clang::BackendConsumer::getBestLocationFromDebugLoc(), clang::FileManager::getBufferForFile(), clang::ASTUnit::getBufferForFile(), getDirectoryFromFile(), clang::FileManager::getFile(), clang::PresumedLoc::getFilename(), getFileName(), clang::FileManager::getFileRef(), clang::FileManager::getOptionalFileRef(), clang::tooling::dependencies::DependencyScanningFilesystemSharedCache::CacheShard::getOrEmplaceEntryForFilename(), clang::tooling::dependencies::DependencyScanningFilesystemSharedCache::CacheShard::getOrEmplaceRealPathForFilename(), clang::tooling::dependencies::DependencyScanningFilesystemSharedCache::CacheShard::getOrInsertEntryForFilename(), clang::tooling::dependencies::DependencyScanningTool::getP1689ModuleDependencyFile(), clang::InMemoryModuleCache::getPCMState(), clang::SourceManager::getPresumedLoc(), getPrivateModuleMap(), getPublicModuleMap(), clang::tooling::dependencies::DependencyScanningFilesystemSharedCache::getShardForFilename(), clang::tooling::dependencies::EntryRef::getStatus(), clang::FileManager::getVirtualFile(), clang::FileManager::getVirtualFileRef(), clang::Preprocessor::HandlePragmaDependency(), clang::tooling::dependencies::DependencyScanningFilesystemLocalCache::insertEntryForFilename(), clang::tooling::dependencies::DependencyScanningFilesystemLocalCache::insertRealPathForFilename(), clang::ModuleDependencyCollector::insertSeen(), clang::ASTReader::isAcceptableASTFile(), clang::FilenamePatternConstraint::isAutoGenerated(), clang::PresumedLoc::isInvalid(), clang::InMemoryModuleCache::isPCMFinal(), isSpecialFilename(), clang::PresumedLoc::isValid(), clang::SourceManager::isWrittenInBuiltinFile(), clang::SourceManager::isWrittenInCommandLineFile(), clang::SourceManager::isWrittenInScratchSpace(), clang::LayoutOverrideSource::LayoutOverrideSource(), clang::tooling::dependencies::ModuleDepCollectorPP::LexedFileChanged(), clang::ASTUnit::LoadFromASTFile(), clang::Preprocessor::LookupEmbedFile(), clang::Preprocessor::LookupFile(), clang::DirectoryLookup::LookupFile(), clang::HeaderSearch::LookupFile(), clang::HeaderMapImpl::lookupFilename(), clang::InMemoryModuleCache::lookupPCM(), clang::HeaderSearch::LookupSubframeworkHeader(), MakeCLOutputFilename(), clang::DependencyCollector::maybeAddDependency(), clang::BackendConsumer::MisExpectDiagHandler(), clang::tooling::dependencies::DependencyScanningWorkerFilesystem::openFileForRead(), ParseDependencyOutputArgs(), ParseDirective(), clang::PresumedLoc::PresumedLoc(), PrintFilename(), PrintHeaderInfo(), clang::ASTReader::readASTFileControlBlock(), clang::serialization::reader::HeaderFileInfoTrait::ReadData(), clang::ASTReader::ReadPath(), clang::ASTReader::ResolveImportedPath(), clang::DependencyCollector::sawDependency(), clang::DependencyFileGenerator::sawDependency(), clang::InMemoryModuleCache::shouldBuildPCM(), clang::XRayFunctionFilter::shouldImbueFunctionsInFile(), clang::format::sortCppIncludes(), clang::tooling::dependencies::DependencyScanningWorkerFilesystem::status(), clang::HeaderSearch::suggestPathToFileForDiagnostics(), clang::TestAST::TestAST(), clang::tooling::transferCompileCommand(), clang::InMemoryModuleCache::tryToDropPCM(), clang::BackendConsumer::UnsupportedDiagHandler(), clang::ento::ExprEngine::ViewGraph(), clang::CXXRecordDecl::viewInheritance(), clang::ChainedASTReaderListener::visitInputFile(), clang::ChainedASTReaderListener::visitModuleFile(), clang::RewriteIncludesAction::RewriteImportsListener::visitModuleFile(), clang::FixItRewriter::WriteFixedFiles(), and clang::driver::XRayArgs::XRayArgs().
StringRef Identifier |
Definition at line 3009 of file Format.cpp.
Referenced by CalculateHiddenNames(), clang::Preprocessor::emitMacroExpansionWarnings(), clang::NestedNameSpecifierLocBuilder::Extend(), clang::CXXScopeSpec::Extend(), clang::DependentTemplateName::getIdentifier(), getTypeIdentifier(), clang::Preprocessor::HandleIdentifier(), clang::Preprocessor::HandlePoisonedIdentifier(), clang::SemaHLSL::handleResourceClassAttr(), clang::Preprocessor::LookUpIdentifierInfo(), clang::Preprocessor::MaybeHandlePoisonedIdentifier(), clang::analyze_format_string::FormatSpecifier::namedTypeToLengthModifier(), clang::DependentTemplateName::Profile(), and clang::format::sortJavaImports().
bool IsStatic |
Definition at line 3013 of file Format.cpp.
Referenced by constructHexagonLinkArgs(), clang::driver::tools::gnutools::Linker::ConstructJob(), clang::driver::tools::nacltools::Linker::ConstructJob(), clang::interp::Program::createGlobal(), clang::format::sortJavaImports(), and clang::interp::Compiler< Emitter >::VisitMaterializeTemporaryExpr().
unsigned Offset |
Definition at line 3003 of file Format.cpp.
int Priority |
Definition at line 3005 of file Format.cpp.
Referenced by clang::SemaOpenMP::ActOnOpenMPPriorityClause(), clang::CodeGen::CodeGenModule::AddCXXPrioritizedStermFinalizerEntry(), clang::CodeGen::CodeGenModule::AddCXXStermFinalizerToGlobalDtor(), clang::CodeGen::CodeGenModule::AddGlobalCtor(), clang::CodeGen::CodeGenModule::AddGlobalDtor(), clang::OMPPriorityClause::children(), clang::SemaCodeCompletion::CodeCompleteConstructorInitializer(), clang::SemaCodeCompletion::CodeCompleteObjCMethodDecl(), clang::SemaCodeCompletion::CodeCompleteObjCPropertySynthesizeIvar(), clang::CodeCompletionBuilder::CodeCompletionBuilder(), clang::CodeGen::CGOpenMPRuntime::emitTaskInit(), clang::getMacroUsagePriority(), clang::OMPPriorityClause::getPriority(), clang::CodeCompletionString::getPriority(), getPrioritySuffix(), clang::tooling::HeaderIncludes::insert(), clang::Sema::mergeAvailabilityAttr(), clang::TreeTransform< Derived >::RebuildOMPPriorityClause(), clang::format::sortCppIncludes(), clang::CodeCompletionBuilder::TakeString(), and TargetMVPriority().
const SourceManager& SM |
Definition at line 2850 of file Format.cpp.
StringRef Text |
Definition at line 3002 of file Format.cpp.
Referenced by clang::comments::Sema::actOnText(), clang::comments::Sema::actOnVerbatimBlockLine(), clang::comments::Sema::actOnVerbatimLine(), clang::CodeCompletionBuilder::AddChunk(), clang::UnsafeBufferUsageHandler::addDebugNoteForVar(), clang::CodeCompletionBuilder::AddInformativeChunk(), clang::CodeCompletionBuilder::AddTextChunk(), clang::CodeCompletionBuilder::AddTypedTextChunk(), clang::format::BreakableBlockComment::BreakableBlockComment(), buildAccessForPointer(), buildAccessForValue(), clang::tooling::buildAddressOf(), clang::tooling::buildDereference(), clang::tooling::buildParens(), clang::SemaCodeCompletion::CodeCompleteAttribute(), clang::format::encoding::columnWidth(), clang::format::encoding::columnWidthWithTabs(), clang::format::BreakableComment::compressWhitespace(), clang::format::configurationAsText(), clang::index::CommentToXMLConverter::convertHTMLTagNodeToText(), clang::format::countLeadingWhitespace(), clang::VerifyDiagnosticConsumer::Directive::create(), createMessage(), clang::tooling::createRenameAtomicChanges(), clang::CodeCompletionString::Chunk::CreateText(), clang::format::encoding::detectEncoding(), clang::format::FindCursorIndex(), clang::format::getCommentSplit(), clang::format::encoding::getEscapeSequenceLength(), clang::format::getLastLineEndColumn(), getRangeText(), clang::ASTContext::getRawCommentForDeclNoCacheImpl(), clang::format::getStringSplit(), clang::format::getStyle(), clang::comments::TextComment::getText(), clang::comments::VerbatimBlockLineComment::getText(), clang::RawComment::hasUnsupportedSplice(), clang::format::WhitespaceManager::inputUsesCRLF(), clang::tooling::AtomicChange::insert(), clang::format::BreakableBlockComment::insertBreak(), clang::format::BreakableLineCommentSection::insertBreak(), clang::ast_matchers::internal::isTokenAtLoc(), clang::comments::TextTokenRetokenizer::lexDelimitedSeq(), clang::comments::TextTokenRetokenizer::lexParHeading(), clang::comments::TextTokenRetokenizer::lexType(), clang::comments::TextTokenRetokenizer::lexWord(), clang::format::loadAndParseConfigFile(), clang::tooling::parseIWYUPragma(), clang::comments::Parser::parseVerbatimLine(), clang::format::IntegerLiteralSeparatorFixer::process(), clang::tooling::AtomicChange::replace(), clang::tooling::replaceStmtWithText(), clang::comments::Token::setText(), clang::comments::Token::setVerbatimBlockText(), clang::comments::Token::setVerbatimLineText(), shouldWarnOnMacroDef(), clang::syntax::FileRange::text(), clang::comments::TextComment::TextComment(), and clang::comments::VerbatimBlockLineComment::VerbatimBlockLineComment().