clang API Documentation
Encodes a location in the source. The SourceManager can decode this to get at the full include stack, line and column information. More...
#include <SourceLocation.h>

Public Member Functions | |
| SourceLocation () | |
| bool | isFileID () const |
| bool | isMacroID () const |
| bool | isValid () const |
| Return true if this is a valid SourceLocation object. | |
| bool | isInvalid () const |
| SourceLocation | getLocWithOffset (int Offset) const |
| Return a source location with the specified offset from this SourceLocation. | |
| unsigned | getRawEncoding () const |
| void * | getPtrEncoding () const |
| void | print (raw_ostream &OS, const SourceManager &SM) const |
| void | dump (const SourceManager &SM) const |
Static Public Member Functions | |
| static SourceLocation | getFromRawEncoding (unsigned Encoding) |
| static SourceLocation | getFromPtrEncoding (void *Encoding) |
Friends | |
| class | SourceManager |
| class | ASTReader |
| class | ASTWriter |
Encodes a location in the source. The SourceManager can decode this to get at the full include stack, line and column information.
Technically, a source location is simply an offset into the manager's view of the input source, which is all input buffers (including macro expansions) concatenated in an effectively arbitrary order. The manager actually maintains two blocks of input buffers. One, starting at offset 0 and growing upwards, contains all buffers from this module. The other, starting at the highest possible offset and growing downwards, contains buffers of loaded modules.
In addition, one bit of SourceLocation is used for quick access to the information whether the location is in a file or a macro expansion.
It is important that this type remains small. It is currently 32 bits wide.
Definition at line 84 of file SourceLocation.h.
| clang::SourceLocation::SourceLocation | ( | ) | [inline] |
Definition at line 94 of file SourceLocation.h.
| void SourceLocation::dump | ( | const SourceManager & | SM | ) | const |
Definition at line 64 of file SourceLocation.cpp.
Referenced by clang::arcmt::trans::MigrationContext::dumpGCAttrs(), and clang::Preprocessor::DumpLocation().
| static SourceLocation clang::SourceLocation::getFromPtrEncoding | ( | void * | Encoding | ) | [inline, static] |
getFromPtrEncoding - Turn a pointer encoding of a SourceLocation object into a real SourceLocation.
Definition at line 163 of file SourceLocation.h.
References getFromRawEncoding().
| static SourceLocation clang::SourceLocation::getFromRawEncoding | ( | unsigned | Encoding | ) | [inline, static] |
getFromRawEncoding - Turn a raw encoding of a SourceLocation object into a real SourceLocation.
Definition at line 145 of file SourceLocation.h.
Referenced by clang::ASTWriter::AddDeclarationNameLoc(), clang::idx::ASTLocation::AsNamedRef(), checkAllProps(), clang::Lexer::ComputePreamble(), clang::DependentDiagnostic::getAccessLoc(), clang::Token::getAnnotationEndLoc(), clang::AttributedTypeLoc::getAttrEnumOperandLoc(), clang::DeclaratorChunk::FunctionTypeInfo::getConstQualifierLoc(), clang::DeclarationNameInfo::getCXXLiteralOperatorNameLoc(), clang::DeclarationNameInfo::getCXXOperatorNameRange(), clang::Designator::getDotLoc(), clang::DesignatedInitExpr::Designator::getDotLoc(), clang::Designator::getEllipsisLoc(), clang::DeclaratorChunk::FunctionTypeInfo::getEllipsisLoc(), clang::DesignatedInitExpr::Designator::getEllipsisLoc(), clang::DeclarationNameInfo::getEndLoc(), clang::DeclaratorChunk::FunctionTypeInfo::getExceptionSpecLoc(), clang::SrcMgr::ExpansionInfo::getExpansionLocEnd(), clang::SrcMgr::ExpansionInfo::getExpansionLocStart(), clang::Designator::getFieldLoc(), clang::DesignatedInitExpr::Designator::getFieldLoc(), getFromPtrEncoding(), llvm::PointerLikeTypeTraits< clang::SourceLocation >::getFromVoidPointer(), GetFullTypeForDeclarator(), clang::SrcMgr::FileInfo::getIncludeLoc(), clang::Designator::getLBracketLoc(), clang::DesignatedInitExpr::Designator::getLBracketLoc(), clang::MMToken::getLocation(), clang::DeclaratorChunk::FunctionTypeInfo::getMutableLoc(), clang::Designator::getRBracketLoc(), clang::DesignatedInitExpr::Designator::getRBracketLoc(), clang::DeclaratorChunk::FunctionTypeInfo::getRefQualifierLoc(), clang::InitializedEntity::getReturnLoc(), clang::DesignatedInitExpr::getSourceRange(), clang::SrcMgr::ExpansionInfo::getSpellingLoc(), clang::TemplateArgumentLocInfo::getTemplateEllipsisLoc(), clang::TemplateArgumentLocInfo::getTemplateNameLoc(), clang::InitializedEntity::getThrowLoc(), clang::DeclaratorChunk::FunctionTypeInfo::getVolatileQualifierLoc(), clang::BackendConsumer::InlineAsmDiagHandler(), clang::SrcMgr::ExpansionInfo::isMacroArgExpansion(), clang::ASTReader::ReadPendingInstantiations(), clang::ASTReader::ReadReferencedSelectors(), clang::ASTReader::ReadSourceLocation(), clang::ASTReader::ReadUsedVTables(), clang::ASTReader::ReadWeakUndeclaredIdentifiers(), clang::TreeTransform< Derived >::RebuildCXXOperatorCallExpr(), and TranslateSLoc().
| SourceLocation clang::SourceLocation::getLocWithOffset | ( | int | Offset | ) | const [inline] |
Return a source location with the specified offset from this SourceLocation.
Definition at line 130 of file SourceLocation.h.
Referenced by clang::html::AddHeaderFooterInternalBuiltinCSS(), clang::Lexer::AdvanceToTokenCharacter(), AreTokensAdjacent(), clang::TokenConcatenation::AvoidConcat(), clang::Sema::CheckAssignmentOperands(), ConvertBackendLocation(), clang::Preprocessor::EnterSourceFile(), clang::ASTReader::FindFileRegionDecls(), clang::arcmt::trans::findLocationAfterSemi(), clang::Lexer::findLocationAfterToken(), clang::DeclSpec::Finish(), FixDigraph(), getBeginningOfFileToken(), clang::Lexer::GetBeginningOfToken(), clang::SourceManager::getImmediateSpellingLoc(), clang::ASTUnit::getLocation(), clang::Lexer::getLocForEndOfToken(), clang::SourceManager::getMacroArgExpandedLocation(), GetMappedTokenLoc(), clang::SourceManager::getPresumedLoc(), clang::PTHLexer::getSourceLocation(), clang::Lexer::getSourceLocation(), clang::ASTUnit::PreambleData::getSourceRange(), getStandardSelLoc(), clang::ScratchBuffer::getToken(), clang::ASTImporter::Import(), clang::BackendConsumer::InlineAsmDiagHandler2(), clang::Lexer::isAtEndOfMacroExpansion(), isEmptyARCMTMacroStatement(), clang::PTHLexer::Lex(), clang::Lexer::makeFileCharRange(), clang::ASTUnit::mapLocationFromPreamble(), clang::ASTUnit::mapLocationToPreamble(), ParseDirective(), clang::PCHValidator::ReadPredefinesBuffer(), clang::ASTReader::ReadSourceLocation(), clang::SourceManager::translateLineCol(), clang::Sema::tryToRecoverWithCall(), and updateConsecutiveMacroArgTokens().
| void* clang::SourceLocation::getPtrEncoding | ( | ) | const [inline] |
getPtrEncoding - When a SourceLocation itself cannot be used, this returns an (opaque) pointer encoding for it. This should only be passed to SourceLocation::getFromPtrEncoding, it should not be inspected directly.
Definition at line 155 of file SourceLocation.h.
References getRawEncoding().
Referenced by llvm::PointerLikeTypeTraits< clang::SourceLocation >::getAsVoidPointer().
| unsigned clang::SourceLocation::getRawEncoding | ( | ) | const [inline] |
getRawEncoding - When a SourceLocation itself cannot be used, this returns an (opaque) 32-bit integer encoding for it. This should only be passed to SourceLocation::getFromRawEncoding, it should not be inspected directly.
Definition at line 141 of file SourceLocation.h.
Referenced by clang::ASTWriter::AddSourceLocation(), clang::idx::ASTLocation::ASTLocation(), checkAllAtProps(), checkAllProps(), checkWeakGCAttrs(), clearRedundantStrongs(), compare_vd_entries(), clang::Lexer::ComputePreamble(), clang::DependentDiagnostic::Create(), clang::SrcMgr::ExpansionInfo::create(), clang::DeclarationNameLoc::DeclarationNameLoc(), clang::DesignatedInitExpr::Designator::Designator(), clang::Designator::getArray(), clang::Designator::getArrayRange(), getAsmSrcLocInfo(), clang::Designator::getField(), clang::DeclaratorChunk::getFunction(), clang::ASTContext::getNameForTemplate(), clang::Sema::GetNameFromUnqualifiedId(), clang::DeclaratorChunk::getPointer(), getPtrEncoding(), clang::Sema::getTypeName(), clang::operator<(), clang::operator==(), clang::ASTReader::ReadDeclarationNameLoc(), clang::Token::setAnnotationEndLoc(), clang::AttributedTypeLoc::setAttrEnumOperandLoc(), clang::DeclarationNameInfo::setCXXLiteralOperatorNameLoc(), clang::DeclarationNameInfo::setCXXOperatorNameRange(), clang::serialization::DeclOffset::setLocation(), clang::UnqualifiedId::setOperatorFunctionId(), clang::Designator::setRBracketLoc(), clang::TemplateArgumentLocInfo::TemplateArgumentLocInfo(), and TranslateSLoc().
| bool clang::SourceLocation::isFileID | ( | ) | const [inline] |
Definition at line 96 of file SourceLocation.h.
Referenced by clang::TokenConcatenation::AvoidConcat(), clang::Sema::CheckAssignmentOperands(), CompactPathDiagnostic(), clang::DoPrintPreprocessedInput(), getBeginningOfFileToken(), clang::Lexer::GetBeginningOfToken(), clang::SourceManager::getDecomposedExpansionLoc(), clang::SourceManager::getDecomposedSpellingLoc(), clang::SourceManager::getExpansionLoc(), clang::SourceManager::getExpansionRange(), clang::SourceManager::getFileLoc(), clang::Lexer::getImmediateMacroName(), clang::SourceManager::getImmediateSpellingLoc(), clang::SourceManager::getMacroArgExpandedLocation(), llvm::DOTGraphTraits< ExplodedNode * >::getNodeLabel(), clang::Lexer::getSourceLocation(), clang::SourceManager::getSpellingLoc(), handleNonNullAttr(), clang::ModuleMap::inferModuleFromLocation(), clang::Lexer::isAtEndOfMacroExpansion(), clang::Lexer::isAtStartOfMacroExpansion(), isEmptyARCMTMacroStatement(), clang::Rewriter::isRewritable(), clang::Lexer::makeFileCharRange(), makeRangeFromFileLocs(), print(), and SuggestParentheses().
| bool clang::SourceLocation::isInvalid | ( | ) | const [inline] |
Definition at line 105 of file SourceLocation.h.
Referenced by clang::Sema::ActOnBaseSpecifier(), clang::Sema::ActOnCXXMemberDeclarator(), clang::Sema::ActOnExplicitInstantiation(), clang::Sema::ActOnPropertyImplDecl(), clang::Sema::ActOnTemplateTemplateParameter(), clang::ASTUnit::addFileLevelDecl(), clang::Declarator::AddTypeInfo(), clang::Sema::BuildClassMessage(), clang::Sema::BuildInstanceMessage(), checkAllProps(), clang::Sema::CheckEquivalentExceptionSpec(), clang::Sema::CheckSpecializationInstantiationRedecl(), ConvertDeclSpecToType(), clang::Sema::DiagnoseEqualityWithExtraParens(), DiagnoseSelfAssignment(), clang::Sema::DiagnoseSentinelCalls(), DoMarkVarDeclReferenced(), clang::CodeGen::CGDebugInfo::EmitLocation(), clang::CXXScopeSpec::Extend(), clang::Declarator::ExtendWithDeclSpec(), clang::arcmt::trans::findLocationAfterSemi(), GenerateFixForUnusedDecl(), clang::ModuleMap::getContainingModuleMapFile(), clang::SrcMgr::ExpansionInfo::getExpansionLocEnd(), clang::SourceManager::getFileCharacteristic(), clang::Lexer::getLocForEndOfToken(), clang::SourceManager::getMacroArgExpandedLocation(), clang::SourceManager::getPresumedLoc(), clang::ClassTemplateSpecializationDecl::getSourceRange(), clang::CallExpr::getSourceRange(), clang::MemberExpr::getSourceRange(), clang::CompoundLiteralExpr::getSourceRange(), clang::InitListExpr::getSourceRange(), getStandardSelLoc(), clang::DesignatedInitExpr::Designator::getStartLocation(), clang::ASTImporter::Import(), clang::ModuleMap::inferModuleFromLocation(), clang::ASTWriter::inferSubmoduleIDFromLocation(), clang::TagTypeLoc::isDefinition(), isEmptyARCMTMacroStatement(), clang::ASTUnit::isInMainFileID(), clang::ASTUnit::isInPreambleFileID(), isInvalid(), clang::SrcMgr::ExpansionInfo::isMacroArgExpansion(), isPreprocessedEntityIfInFileID(), clang::ASTReader::isPreprocessedEntityInFileID(), isValidDeadStmt(), clang::CompilerInstance::loadModule(), clang::Lexer::makeFileCharRange(), makeRangeFromFileLocs(), clang::ASTUnit::mapLocationFromPreamble(), clang::ASTUnit::mapLocationToPreamble(), clang::Sema::MarkFunctionReferenced(), MarkVarDeclODRUsed(), MoveUpIncludeHierarchy(), clang::Sema::PerformCopyInitialization(), clang::PrettyStackTraceParserEntry::print(), clang::PrettyStackTraceDecl::print(), ReadLineMarkerFlags(), clang::Sema::RequireCompleteDeclContext(), clang::Sema::RequireCompleteExprType(), clang::arcmt::trans::MigrationContext::rewritePropertyAttribute(), clang::DiagnosticsEngine::setDiagnosticMapping(), clang::CXXScopeSpec::SetInvalid(), clang::Declarator::SetRangeBegin(), clang::Declarator::SetRangeEnd(), clang::VarDecl::setTemplateSpecializationKind(), clang::StoredDiagnostic::StoredDiagnostic(), and clang::Declarator::takeAttributes().
| bool clang::SourceLocation::isMacroID | ( | ) | const [inline] |
Definition at line 97 of file SourceLocation.h.
Referenced by clang::arcmt::trans::MigrationContext::addPropertyAttribute(), checkAllAtProps(), clang::Sema::CheckCompareOperands(), clang::Sema::CheckLogicalOperands(), CompactPathDiagnostic(), clang::ento::containsMacro(), diagnoseBadTypeAttribute(), DiagnoseBinOpPrecedence(), clang::Sema::DiagnoseEqualityWithExtraParens(), DiagnoseSelfAssignment(), DiagnoseUnusedComparison(), clang::TextDiagnostic::emitDiagnosticLoc(), clang::CodeGen::CGDebugInfo::EmitLocation(), clang::Lexer::findLocationAfterToken(), clang::Sema::findMacroSpelling(), clang::arcmt::trans::findSemiAfterLocation(), getDiagnosticPresumedLoc(), clang::SourceManager::getImmediateExpansionRange(), getImmediateMacroCalleeLoc(), getImmediateMacroCallerLoc(), getImmediateMacroName(), clang::Lexer::getImmediateMacroName(), clang::Lexer::getLocForEndOfToken(), clang::ento::CheckerContext::getMacroNameOrSpelling(), GetMappedTokenLoc(), handleObjCOwnershipTypeAttr(), clang::html::HighlightMacros(), clang::Lexer::isAtEndOfMacroExpansion(), clang::Lexer::isAtStartOfMacroExpansion(), isEmptyARCMTMacroStatement(), clang::SourceManager::isInSystemMacro(), clang::SourceManager::isMacroArgExpansion(), clang::PreprocessingRecord::MacroExpands(), clang::Lexer::makeFileCharRange(), clang::arcmt::trans::MigrationContext::rewritePropertyAttribute(), and skipToMacroArgExpansion().
| bool clang::SourceLocation::isValid | ( | ) | const [inline] |
Return true if this is a valid SourceLocation object.
Invalid SourceLocations are often used when events have no corresponding location in the source (e.g. a diagnostic is required for a command line option).
Definition at line 104 of file SourceLocation.h.
Referenced by clang::Sema::ActOnAliasDeclaration(), clang::Sema::ActOnClassTemplateSpecialization(), clang::Sema::ActOnCXXMemberDeclarator(), clang::Sema::ActOnDependentTemplateName(), clang::Sema::ActOnFinishLinkageSpecification(), clang::Sema::ActOnIdExpression(), clang::Sema::ActOnModuleImport(), clang::Sema::ActOnPropertyImplDecl(), clang::Sema::ActOnStartCXXMemberDeclarations(), clang::Sema::ActOnStartNamespaceDef(), clang::Sema::ActOnTag(), clang::Sema::ActOnTemplateParameterList(), clang::Sema::ActOnTemplateTemplateParameter(), clang::Sema::ActOnTypenameType(), clang::Sema::ActOnUsingDirective(), clang::Sema::AddCFAuditedAttribute(), clang::ento::PathDiagnosticPiece::addRange(), clang::Sema::BuildBaseInitializer(), clang::Sema::BuildClassMessage(), clang::Sema::BuildCXXNew(), clang::Sema::BuildInstanceMessage(), clang::Sema::BuildMemInitializer(), clang::Sema::BuildPossibleImplicitMemberExpr(), clang::Sema::BuildQualifiedTemplateIdExpr(), clang::BuildRecoveryCallExpr(), clang::Sema::CheckBaseSpecifier(), clang::Sema::CheckClassTemplate(), clang::Sema::CheckExceptionSpecSubset(), clang::Sema::CheckFieldDecl(), clang::Sema::CheckPureMethod(), clang::Sema::CheckSpecializationInstantiationRedecl(), clang::Sema::CheckTypenameType(), clang::DeclRefExpr::Create(), clang::MemberExpr::Create(), clang::UnresolvedLookupExpr::Create(), clang::DependentScopeDeclRefExpr::Create(), clang::CXXDependentScopeMemberExpr::Create(), clang::UnresolvedMemberExpr::Create(), clang::Preprocessor::CreateString(), clang::CXXMethodDecl::CXXMethodDecl(), DiagLocForExplicitInstantiation(), DiagnoseIgnoredQualifiers(), diagnoseObjCARCConversion(), DiagnoseTemplateParameterListArityMismatch(), clang::CodeGen::CodeGenFunction::EmitDeclRefLValue(), clang::DiagnosticRenderer::emitDiagnostic(), EvaluateDefined(), clang::NestedNameSpecifierLocBuilder::Extend(), clang::SourceManager::getMacroArgExpandedLocation(), clang::DeclarationNameInfo::getSourceRange(), clang::CXXConstructExpr::getSourceRange(), clang::ObjCPropertyImplDecl::getSourceRange(), clang::TagDecl::getSourceRange(), getValidSourceLocation(), handleAvailabilityAttr(), clang::TextDiagnosticPrinter::HandleDiagnostic(), clang::LogDiagnosticPrinter::HandleDiagnostic(), clang::Preprocessor::HandleEndOfFile(), handleObjCGCTypeAttr(), handleObjCOwnershipTypeAttr(), clang::PragmaUnusedHandler::HandlePragma(), clang::LinkageSpecDecl::hasBraces(), clang::Declarator::hasEllipsis(), clang::DeclRefExpr::hasExplicitTemplateArgs(), clang::OverloadExpr::hasExplicitTemplateArgs(), clang::MemberExpr::hasExplicitTemplateArgs(), clang::DependentScopeDeclRefExpr::hasExplicitTemplateArgs(), clang::CXXDependentScopeMemberExpr::hasExplicitTemplateArgs(), clang::DeclaratorChunk::FunctionTypeInfo::hasMutableQualifier(), clang::DeclaratorChunk::FunctionTypeInfo::hasRefQualifier(), clang::DeclRefExpr::hasTemplateKeyword(), clang::OverloadExpr::hasTemplateKeyword(), clang::MemberExpr::hasTemplateKeyword(), clang::DependentScopeDeclRefExpr::hasTemplateKeyword(), clang::CXXDependentScopeMemberExpr::hasTemplateKeyword(), clang::Sema::ImplicitlyDefineFunction(), clang::TokenLexer::Init(), clang::ASTTemplateKWAndArgsInfo::initializeFrom(), clang::BackendConsumer::InlineAsmDiagHandler2(), clang::Lexer::isAtEndOfMacroExpansion(), clang::Lexer::isAtStartOfMacroExpansion(), clang::SourceManager::isBeforeInTranslationUnit(), clang::FullSourceLoc::isBeforeInTranslationUnitThan(), clang::InitListExpr::isExplicit(), clang::Declarator::isFirstDeclarator(), clang::SrcMgr::ExpansionInfo::isFunctionMacroExpansion(), clang::Sema::isIncompatibleTypedef(), clang::SrcMgr::ExpansionInfo::isMacroArgExpansion(), clang::DeclSpec::isModulePrivateSpecified(), clang::CXXBaseSpecifier::isPackExpansion(), clang::LambdaExpr::Capture::isPackExpansion(), clang::CXXCtorInitializer::isPackExpansion(), clang::SourceRange::isValid(), clang::UnqualifiedId::isValid(), clang::TokenLexer::Lex(), clang::Sema::LookupOrCreateLabel(), MatchTemplateParameterKind(), clang::Sema::MatchTemplateParametersToScopeSpecifier(), clang::Sema::MergeTypedefNameDecl(), clang::OverloadExpr::OverloadExpr(), clang::ento::PathDiagnosticSpotPiece::PathDiagnosticSpotPiece(), PerformConstructorInitialization(), clang::PrettyStackTraceLoc::print(), clang::PrettyDeclStackTraceEntry::print(), print(), clang::PrettyStackTraceDecl::print(), clang::TreeTransform< Derived >::RebuildDependentScopeDeclRefExpr(), clang::arcmt::trans::MigrationContext::rewritePropertyAttribute(), clang::CodeGen::CGDebugInfo::setLocation(), clang::ClassTemplateSpecializationDecl::setPointOfInstantiation(), clang::VarDecl::setTemplateSpecializationKind(), clang::FunctionDecl::setTemplateSpecializationKind(), clang::StoredDiagnostic::StoredDiagnostic(), SuggestParentheses(), clang::TreeTransform< Derived >::TemporaryBase::TemporaryBase(), and translateTemplateArgument().
| void SourceLocation::print | ( | raw_ostream & | OS, |
| const SourceManager & | SM | ||
| ) | const |
Definition at line 38 of file SourceLocation.cpp.
References clang::PresumedLoc::getColumn(), clang::SourceManager::getExpansionLoc(), clang::PresumedLoc::getFilename(), clang::PresumedLoc::getLine(), clang::SourceManager::getPresumedLoc(), clang::SourceManager::getSpellingLoc(), isFileID(), clang::PresumedLoc::isInvalid(), isValid(), and print().
Referenced by clang::PrettyStackTraceLoc::print(), clang::PrettyDeclStackTraceEntry::print(), clang::PrettyStackTraceParserEntry::print(), clang::idx::ASTLocation::print(), print(), and clang::PrettyStackTraceDecl::print().
friend class ASTReader [friend] |
Definition at line 87 of file SourceLocation.h.
friend class ASTWriter [friend] |
Definition at line 88 of file SourceLocation.h.
friend class SourceManager [friend] |
Definition at line 86 of file SourceLocation.h.