clang API Documentation

Classes | Public Types | Public Member Functions | Static Public Member Functions | Friends
clang::ASTUnit Class Reference

Utility class for loading a ASTContext from an AST file. More...

#include <ASTUnit.h>

Inheritance diagram for clang::ASTUnit:
Inheritance graph
[legend]
Collaboration diagram for clang::ASTUnit:
Collaboration graph
[legend]

List of all members.

Classes

struct  CachedCodeCompletionResult
 A cached code-completion result, which may be introduced in one of many different contexts. More...
class  ConcurrencyCheck
class  ConcurrencyState
 Allows us to assert that ASTUnit is not being used concurrently, which is not supported.
class  PreambleData

Public Types

typedef std::vector< Decl * >
::iterator 
top_level_iterator
typedef StoredDiagnosticstored_diag_iterator
typedef const StoredDiagnosticstored_diag_const_iterator
typedef std::vector
< CachedCodeCompletionResult >
::iterator 
cached_completion_iterator
typedef llvm::PointerUnion
< const char *, const
llvm::MemoryBuffer * > 
FilenameOrMemBuf
typedef std::pair< std::string,
FilenameOrMemBuf
RemappedFile
 A mapping from a file name to the memory buffer that stores the remapped contents of that file.

Public Member Functions

const PreambleDatagetPreambleData () const
llvm::StringMap< unsigned > & getCachedCompletionTypes ()
 Retrieve the mapping from formatted type names to unique type identifiers.
IntrusiveRefCntPtr
< GlobalCodeCompletionAllocator
getCachedCompletionAllocator ()
 Retrieve the allocator used to cache global code completions.
CodeCompletionTUInfogetCodeCompletionTUInfo ()
 ~ASTUnit ()
bool isMainFileAST () const
bool isUnsafeToFree () const
void setUnsafeToFree (bool Value)
const DiagnosticsEnginegetDiagnostics () const
DiagnosticsEnginegetDiagnostics ()
const SourceManagergetSourceManager () const
SourceManagergetSourceManager ()
const PreprocessorgetPreprocessor () const
PreprocessorgetPreprocessor ()
const ASTContextgetASTContext () const
ASTContextgetASTContext ()
void setASTContext (ASTContext *ctx)
void setPreprocessor (Preprocessor *pp)
bool hasSema () const
SemagetSema () const
const FileManagergetFileManager () const
FileManagergetFileManager ()
const FileSystemOptionsgetFileSystemOpts () const
const std::string & getOriginalSourceFileName ()
void addTemporaryFile (const llvm::sys::Path &TempFile)
 Add a temporary file that the ASTUnit depends on.
bool getOnlyLocalDecls () const
bool getOwnsRemappedFileBuffers () const
void setOwnsRemappedFileBuffers (bool val)
StringRef getMainFileName () const
top_level_iterator top_level_begin ()
top_level_iterator top_level_end ()
std::size_t top_level_size () const
bool top_level_empty () const
void addTopLevelDecl (Decl *D)
 Add a new top-level declaration.
void addFileLevelDecl (Decl *D)
 Add a new local file-level declaration.
void findFileRegionDecls (FileID File, unsigned Offset, unsigned Length, SmallVectorImpl< Decl * > &Decls)
 Get the decls that are contained in a file in the Offset/Length range.
void addTopLevelDeclFromPreamble (serialization::DeclID D)
 Add a new top-level declaration, identified by its ID in the precompiled preamble.
unsigned & getCurrentTopLevelHashValue ()
 Retrieve a reference to the current top-level name hash value.
SourceLocation getLocation (const FileEntry *File, unsigned Line, unsigned Col) const
 Get the source location for the given file:line:col triplet.
SourceLocation getLocation (const FileEntry *File, unsigned Offset) const
 Get the source location for the given file:offset pair.
SourceLocation mapLocationFromPreamble (SourceLocation Loc)
 If.
SourceLocation mapLocationToPreamble (SourceLocation Loc)
 If.
bool isInPreambleFileID (SourceLocation Loc)
bool isInMainFileID (SourceLocation Loc)
SourceLocation getStartOfMainFileID ()
SourceLocation getEndOfPreambleFileID ()
SourceRange mapRangeFromPreamble (SourceRange R)
SourceRange mapRangeToPreamble (SourceRange R)
stored_diag_const_iterator stored_diag_begin () const
stored_diag_iterator stored_diag_begin ()
stored_diag_const_iterator stored_diag_end () const
stored_diag_iterator stored_diag_end ()
unsigned stored_diag_size () const
stored_diag_iterator stored_diag_afterDriver_begin ()
cached_completion_iterator cached_completion_begin ()
cached_completion_iterator cached_completion_end ()
unsigned cached_completion_size () const
llvm::MemoryBuffer * getBufferForFile (StringRef Filename, std::string *ErrorStr=0)
TranslationUnitKind getTranslationUnitKind () const
 Determine what kind of translation unit this AST represents.
bool Reparse (RemappedFile *RemappedFiles=0, unsigned NumRemappedFiles=0)
 Reparse the source files using the same command-line options that were originally used to produce this translation unit.
void CodeComplete (StringRef File, unsigned Line, unsigned Column, RemappedFile *RemappedFiles, unsigned NumRemappedFiles, bool IncludeMacros, bool IncludeCodePatterns, CodeCompleteConsumer &Consumer, DiagnosticsEngine &Diag, LangOptions &LangOpts, SourceManager &SourceMgr, FileManager &FileMgr, SmallVectorImpl< StoredDiagnostic > &StoredDiagnostics, SmallVectorImpl< const llvm::MemoryBuffer * > &OwnedBuffers)
 Perform code completion at the given file, line, and column within this translation unit.
CXSaveError Save (StringRef File)
 Save this translation unit to a file with the given name.
bool serialize (raw_ostream &OS)
 Serialize this translation unit with the given output stream.
virtual ModuleloadModule (SourceLocation ImportLoc, ModuleIdPath Path, Module::NameVisibilityKind Visibility, bool IsInclusionDirective)
 Attempt to load the given module.

Static Public Member Functions

static ASTUnitcreate (CompilerInvocation *CI, IntrusiveRefCntPtr< DiagnosticsEngine > Diags, bool CaptureDiagnostics=false)
 Create a ASTUnit. Gets ownership of the passed CompilerInvocation.
static ASTUnitLoadFromASTFile (const std::string &Filename, IntrusiveRefCntPtr< DiagnosticsEngine > Diags, const FileSystemOptions &FileSystemOpts, bool OnlyLocalDecls=false, RemappedFile *RemappedFiles=0, unsigned NumRemappedFiles=0, bool CaptureDiagnostics=false, bool AllowPCHWithCompilerErrors=false)
 Create a ASTUnit from an AST file.
static ASTUnitLoadFromCompilerInvocationAction (CompilerInvocation *CI, IntrusiveRefCntPtr< DiagnosticsEngine > Diags, ASTFrontendAction *Action=0, ASTUnit *Unit=0, bool Persistent=true, StringRef ResourceFilesPath=StringRef(), bool OnlyLocalDecls=false, bool CaptureDiagnostics=false, bool PrecompilePreamble=false, bool CacheCodeCompletionResults=false, OwningPtr< ASTUnit > *ErrAST=0)
 Create an ASTUnit from a source file, via a CompilerInvocation object, by invoking the optionally provided ASTFrontendAction.
static ASTUnitLoadFromCompilerInvocation (CompilerInvocation *CI, IntrusiveRefCntPtr< DiagnosticsEngine > Diags, bool OnlyLocalDecls=false, bool CaptureDiagnostics=false, bool PrecompilePreamble=false, TranslationUnitKind TUKind=TU_Complete, bool CacheCodeCompletionResults=false)
static ASTUnitLoadFromCommandLine (const char **ArgBegin, const char **ArgEnd, IntrusiveRefCntPtr< DiagnosticsEngine > Diags, StringRef ResourceFilesPath, bool OnlyLocalDecls=false, bool CaptureDiagnostics=false, RemappedFile *RemappedFiles=0, unsigned NumRemappedFiles=0, bool RemappedFilesKeepOriginalName=true, bool PrecompilePreamble=false, TranslationUnitKind TUKind=TU_Complete, bool CacheCodeCompletionResults=false, bool AllowPCHWithCompilerErrors=false, bool SkipFunctionBodies=false, OwningPtr< ASTUnit > *ErrAST=0)

Friends

class ConcurrencyCheck

Detailed Description

Utility class for loading a ASTContext from an AST file.

Definition at line 61 of file ASTUnit.h.


Member Typedef Documentation

Definition at line 586 of file ASTUnit.h.

typedef llvm::PointerUnion<const char *, const llvm::MemoryBuffer *> clang::ASTUnit::FilenameOrMemBuf

Definition at line 607 of file ASTUnit.h.

typedef std::pair<std::string, FilenameOrMemBuf> clang::ASTUnit::RemappedFile

A mapping from a file name to the memory buffer that stores the remapped contents of that file.

Definition at line 610 of file ASTUnit.h.

Definition at line 564 of file ASTUnit.h.

Definition at line 563 of file ASTUnit.h.

typedef std::vector<Decl *>::iterator clang::ASTUnit::top_level_iterator

Definition at line 473 of file ASTUnit.h.


Constructor & Destructor Documentation

ASTUnit::~ASTUnit ( )

Member Function Documentation

void ASTUnit::addFileLevelDecl ( Decl D)
void ASTUnit::addTemporaryFile ( const llvm::sys::Path &  TempFile)

Add a temporary file that the ASTUnit depends on.

This file will be erased when the ASTUnit is destroyed.

Definition at line 193 of file ASTUnit.cpp.

References getOnDiskData().

void clang::ASTUnit::addTopLevelDecl ( Decl D) [inline]

Add a new top-level declaration.

Definition at line 500 of file ASTUnit.h.

void clang::ASTUnit::addTopLevelDeclFromPreamble ( serialization::DeclID  D) [inline]

Add a new top-level declaration, identified by its ID in the precompiled preamble.

Definition at line 515 of file ASTUnit.h.

cached_completion_iterator clang::ASTUnit::cached_completion_begin ( ) [inline]

Definition at line 588 of file ASTUnit.h.

cached_completion_iterator clang::ASTUnit::cached_completion_end ( ) [inline]

Definition at line 592 of file ASTUnit.h.

unsigned clang::ASTUnit::cached_completion_size ( ) const [inline]

Definition at line 596 of file ASTUnit.h.

void ASTUnit::CodeComplete ( StringRef  File,
unsigned  Line,
unsigned  Column,
RemappedFile RemappedFiles,
unsigned  NumRemappedFiles,
bool  IncludeMacros,
bool  IncludeCodePatterns,
CodeCompleteConsumer Consumer,
DiagnosticsEngine Diag,
LangOptions LangOpts,
SourceManager SourceMgr,
FileManager FileMgr,
SmallVectorImpl< StoredDiagnostic > &  StoredDiagnostics,
SmallVectorImpl< const llvm::MemoryBuffer * > &  OwnedBuffers 
)

Perform code completion at the given file, line, and column within this translation unit.

Parameters:
FileThe file in which code completion will occur.
LineThe line at which code completion will occur.
ColumnThe column at which code completion will occur.
IncludeMacrosWhether to include macros in the code-completion results.
IncludeCodePatternsWhether to include code patterns (such as a for loop) in the code-completion results.

FIXME: The Diag, LangOpts, SourceMgr, FileMgr, StoredDiagnostics, and OwnedBuffers parameters are all disgusting hacks. They will go away.

Definition at line 2265 of file ASTUnit.cpp.

References clang::PreprocessorOptions::addRemappedFile(), checkAndSanitizeDiags(), clang::PreprocessorOptions::clearRemappedFiles(), clang::FrontendOptions::CodeCompletionAt, clang::ParsedSourceLocation::Column, clang::TargetInfo::CreateTargetInfo(), clang::PreprocessorOptions::DetailedRecord, clang::PreprocessorOptions::DisablePCHValidation, clang::PreprocessorOptions::DisableStatCache, clang::ParsedSourceLocation::FileName, getPreambleFile(), getSourceManager(), clang::IK_AST, clang::IK_LLVM_IR, clang::PreprocessorOptions::ImplicitPCHInclude, clang::ParsedSourceLocation::Line, clang::PreprocessorOptions::PrecompiledPreambleBytes, clang::ProcessWarningOptions(), clang::PreprocessorOptions::RetainRemappedFileBuffers, clang::FrontendOptions::ShowCodePatternsInCodeCompletion, clang::FrontendOptions::ShowGlobalSymbolsInCodeCompletion, clang::FrontendOptions::ShowMacrosInCodeCompletion, clang::ASTUnit::PreambleData::size(), stored_diag_afterDriver_begin(), and stored_diag_begin().

ASTUnit * ASTUnit::create ( CompilerInvocation CI,
IntrusiveRefCntPtr< DiagnosticsEngine Diags,
bool  CaptureDiagnostics = false 
) [static]

Create a ASTUnit. Gets ownership of the passed CompilerInvocation.

Definition at line 1660 of file ASTUnit.cpp.

References clang::CompilerInvocation::getFileSystemOpts().

Referenced by LoadFromCompilerInvocationAction().

void ASTUnit::findFileRegionDecls ( FileID  File,
unsigned  Offset,
unsigned  Length,
SmallVectorImpl< Decl * > &  Decls 
)

Get the decls that are contained in a file in the Offset/Length range.

  • Length can be 0 to indicate a point at
  • Offset instead of a range.

Definition at line 2587 of file ASTUnit.cpp.

References compLocDecl(), clang::ExternalASTSource::FindFileRegionDecls(), clang::ASTContext::getExternalSource(), clang::FileID::isInvalid(), and clang::SourceManager::isLoadedFileID().

const ASTContext& clang::ASTUnit::getASTContext ( ) const [inline]
ASTContext& clang::ASTUnit::getASTContext ( ) [inline]

Definition at line 443 of file ASTUnit.h.

llvm::MemoryBuffer * ASTUnit::getBufferForFile ( StringRef  Filename,
std::string *  ErrorStr = 0 
)

Definition at line 623 of file ASTUnit.cpp.

References clang::FileManager::getBufferForFile().

IntrusiveRefCntPtr<GlobalCodeCompletionAllocator> clang::ASTUnit::getCachedCompletionAllocator ( ) [inline]

Retrieve the allocator used to cache global code completions.

Definition at line 315 of file ASTUnit.h.

llvm::StringMap<unsigned>& clang::ASTUnit::getCachedCompletionTypes ( ) [inline]

Retrieve the mapping from formatted type names to unique type identifiers.

Definition at line 309 of file ASTUnit.h.

CodeCompletionTUInfo& clang::ASTUnit::getCodeCompletionTUInfo ( ) [inline]

Definition at line 319 of file ASTUnit.h.

unsigned& clang::ASTUnit::getCurrentTopLevelHashValue ( ) [inline]

Retrieve a reference to the current top-level name hash value.

Note: This is used internally by the top-level tracking action

Definition at line 522 of file ASTUnit.h.

Referenced by LoadFromCompilerInvocationAction().

const DiagnosticsEngine& clang::ASTUnit::getDiagnostics ( ) const [inline]

Definition at line 433 of file ASTUnit.h.

Referenced by LoadFromCompilerInvocationAction(), Reparse(), and serialize().

DiagnosticsEngine& clang::ASTUnit::getDiagnostics ( ) [inline]

Definition at line 434 of file ASTUnit.h.

SourceLocation ASTUnit::getEndOfPreambleFileID ( )
const FileManager& clang::ASTUnit::getFileManager ( ) const [inline]
FileManager& clang::ASTUnit::getFileManager ( ) [inline]

Definition at line 455 of file ASTUnit.h.

const FileSystemOptions& clang::ASTUnit::getFileSystemOpts ( ) const [inline]

Definition at line 457 of file ASTUnit.h.

SourceLocation ASTUnit::getLocation ( const FileEntry File,
unsigned  Line,
unsigned  Col 
) const

Get the source location for the given file:line:col triplet.

The difference with SourceManager::getLocation is that this method checks whether the requested location points inside the precompiled preamble in which case the returned source location will be a "loaded" one.

Definition at line 2630 of file ASTUnit.cpp.

References clang::SourceManager::getMacroArgExpandedLocation(), getSourceManager(), and clang::SourceManager::translateFileLineCol().

SourceLocation ASTUnit::getLocation ( const FileEntry File,
unsigned  Offset 
) const
StringRef ASTUnit::getMainFileName ( ) const

Definition at line 1656 of file ASTUnit.cpp.

References clang::CompilerInvocation::getFrontendOpts(), and clang::FrontendOptions::Inputs.

Referenced by Reparse().

bool clang::ASTUnit::getOnlyLocalDecls ( ) const [inline]

Definition at line 466 of file ASTUnit.h.

const std::string & ASTUnit::getOriginalSourceFileName ( )

Definition at line 619 of file ASTUnit.cpp.

bool clang::ASTUnit::getOwnsRemappedFileBuffers ( ) const [inline]

Definition at line 468 of file ASTUnit.h.

const PreambleData& clang::ASTUnit::getPreambleData ( ) const [inline]

Definition at line 201 of file ASTUnit.h.

const Preprocessor& clang::ASTUnit::getPreprocessor ( ) const [inline]

Definition at line 439 of file ASTUnit.h.

Referenced by clang::FrontendAction::BeginSourceFile().

Preprocessor& clang::ASTUnit::getPreprocessor ( ) [inline]

Definition at line 440 of file ASTUnit.h.

Sema& clang::ASTUnit::getSema ( ) const [inline]

Definition at line 449 of file ASTUnit.h.

Referenced by serialize().

const SourceManager& clang::ASTUnit::getSourceManager ( ) const [inline]
SourceManager& clang::ASTUnit::getSourceManager ( ) [inline]

Definition at line 437 of file ASTUnit.h.

SourceLocation ASTUnit::getStartOfMainFileID ( )
TranslationUnitKind clang::ASTUnit::getTranslationUnitKind ( ) const [inline]

Determine what kind of translation unit this AST represents.

Definition at line 604 of file ASTUnit.h.

bool clang::ASTUnit::hasSema ( ) const [inline]

Definition at line 448 of file ASTUnit.h.

bool ASTUnit::isInMainFileID ( SourceLocation  Loc)
bool ASTUnit::isInPreambleFileID ( SourceLocation  Loc)
bool clang::ASTUnit::isMainFileAST ( ) const [inline]

Definition at line 428 of file ASTUnit.h.

Referenced by top_level_begin(), top_level_empty(), top_level_end(), and top_level_size().

bool clang::ASTUnit::isUnsafeToFree ( ) const [inline]

Definition at line 430 of file ASTUnit.h.

ASTUnit * ASTUnit::LoadFromASTFile ( const std::string &  Filename,
IntrusiveRefCntPtr< DiagnosticsEngine Diags,
const FileSystemOptions FileSystemOpts,
bool  OnlyLocalDecls = false,
RemappedFile RemappedFiles = 0,
unsigned  NumRemappedFiles = 0,
bool  CaptureDiagnostics = false,
bool  AllowPCHWithCompilerErrors = false 
) [static]

Create a ASTUnit from an AST file.

Parameters:
Filename- The AST file to load.
Diags- The diagnostics engine to use for reporting errors; its lifetime is expected to extend past that of the returned ASTUnit.
Returns:
- The initialized ASTUnit or null if the AST failed to load.

Definition at line 649 of file ASTUnit.cpp.

References clang::ASTReader::Failure, clang::ASTReader::get(), clang::ASTReader::IgnorePCH, clang::ASTReader::InitializeSema(), clang::serialization::MK_MainFile, NULL, and clang::ASTReader::Success.

Referenced by clang::FrontendAction::BeginSourceFile(), and clang::ASTMergeAction::ExecuteAction().

ASTUnit * ASTUnit::LoadFromCommandLine ( const char **  ArgBegin,
const char **  ArgEnd,
IntrusiveRefCntPtr< DiagnosticsEngine Diags,
StringRef  ResourceFilesPath,
bool  OnlyLocalDecls = false,
bool  CaptureDiagnostics = false,
RemappedFile RemappedFiles = 0,
unsigned  NumRemappedFiles = 0,
bool  RemappedFilesKeepOriginalName = true,
bool  PrecompilePreamble = false,
TranslationUnitKind  TUKind = TU_Complete,
bool  CacheCodeCompletionResults = false,
bool  AllowPCHWithCompilerErrors = false,
bool  SkipFunctionBodies = false,
OwningPtr< ASTUnit > *  ErrAST = 0 
) [static]

LoadFromCommandLine - Create an ASTUnit from a vector of command line arguments, which must specify exactly one source file.

Parameters:
ArgBegin- The beginning of the argument vector.
ArgEnd- The end of the argument vector.
Diags- The diagnostics engine to use for reporting errors; its lifetime is expected to extend past that of the returned ASTUnit.
ResourceFilesPath- The path to the compiler resource files.
ErrAST- If non-null and parsing failed without any AST to return (e.g. because the PCH could not be loaded), this accepts the ASTUnit mainly to allow the caller to see the diagnostics.

Definition at line 1868 of file ASTUnit.cpp.

References clang::PreprocessorOptions::AllowPCHWithCompilerErrors, clang::CompilerInstance::createDiagnostics(), clang::createInvocationFromCommandLine(), and clang::PreprocessorOptions::RemappedFilesKeepOriginalName.

ASTUnit * ASTUnit::LoadFromCompilerInvocation ( CompilerInvocation CI,
IntrusiveRefCntPtr< DiagnosticsEngine Diags,
bool  OnlyLocalDecls = false,
bool  CaptureDiagnostics = false,
bool  PrecompilePreamble = false,
TranslationUnitKind  TUKind = TU_Complete,
bool  CacheCodeCompletionResults = false 
) [static]

LoadFromCompilerInvocation - Create an ASTUnit from a source file, via a CompilerInvocation object.

Parameters:
CI- The compiler invocation to use; it must have exactly one input source file. The ASTUnit takes ownership of the CompilerInvocation object.
Diags- The diagnostics engine to use for reporting errors; its lifetime is expected to extend past that of the returned ASTUnit.

Definition at line 1840 of file ASTUnit.cpp.

ASTUnit * ASTUnit::LoadFromCompilerInvocationAction ( CompilerInvocation CI,
IntrusiveRefCntPtr< DiagnosticsEngine Diags,
ASTFrontendAction Action = 0,
ASTUnit Unit = 0,
bool  Persistent = true,
StringRef  ResourceFilesPath = StringRef(),
bool  OnlyLocalDecls = false,
bool  CaptureDiagnostics = false,
bool  PrecompilePreamble = false,
bool  CacheCodeCompletionResults = false,
OwningPtr< ASTUnit > *  ErrAST = 0 
) [static]

Create an ASTUnit from a source file, via a CompilerInvocation object, by invoking the optionally provided ASTFrontendAction.

Parameters:
CI- The compiler invocation to use; it must have exactly one input source file. The ASTUnit takes ownership of the CompilerInvocation object.
Diags- The diagnostics engine to use for reporting errors; its lifetime is expected to extend past that of the returned ASTUnit.
Action- The ASTFrontendAction to invoke. Its ownership is not transfered.
Unit- optionally an already created ASTUnit. Its ownership is not transfered.
Persistent- if true the returned ASTUnit will be complete. false means the caller is only interested in getting info through the provided
See also:
Action.
Parameters:
ErrAST- If non-null and parsing failed without any AST to return (e.g. because the PCH could not be loaded), this accepts the ASTUnit mainly to allow the caller to see the diagnostics. This will only receive an ASTUnit if a new one was created. If an already created ASTUnit was passed in
Unitthen the caller can check that.

Definition at line 1675 of file ASTUnit.cpp.

References clang::FrontendAction::BeginSourceFile(), create(), clang::TargetInfo::CreateTargetInfo(), clang::FrontendOptions::DisableFree, clang::FrontendAction::EndSourceFile(), clang::FrontendAction::Execute(), clang::TargetOptions::Features, getCurrentTopLevelHashValue(), clang::CompilerInvocation::getDiagnosticOpts(), getDiagnostics(), getFileManager(), clang::CompilerInvocation::getFrontendOpts(), clang::CompilerInvocation::getHeaderSearchOpts(), clang::CompilerInvocation::getPreprocessorOpts(), getSourceManager(), clang::CompilerInvocation::getTargetOpts(), clang::FrontendAction::getTranslationUnitKind(), clang::IK_AST, clang::IK_LLVM_IR, clang::ProcessWarningOptions(), clang::HeaderSearchOptions::ResourceDir, clang::PreprocessorOptions::RetainRemappedFileBuffers, and clang::TU_Complete.

Referenced by clang::arcmt::MigrationProcess::applyTransform(), and clang::arcmt::checkForManualIssues().

virtual Module* clang::ASTUnit::loadModule ( SourceLocation  ImportLoc,
ModuleIdPath  Path,
Module::NameVisibilityKind  Visibility,
bool  IsInclusionDirective 
) [inline, virtual]

Attempt to load the given module.

This routine attempts to load the module described by the given parameters.

Parameters:
ImportLocThe location of the 'import' keyword.
PathThe identifiers (and their locations) of the module "path", e.g., "std.vector" would be split into "std" and "vector".
VisibilityThe visibility provided for the names in the loaded module.
IsInclusionDirectiveIndicates that this module is being loaded implicitly, due to the presence of an inclusion directive. Otherwise, it is being loaded due to an import declaration.
Returns:
If successful, returns the loaded module. Otherwise, returns NULL to indicate that the module could not be loaded.

Implements clang::ModuleLoader.

Definition at line 781 of file ASTUnit.h.

SourceLocation ASTUnit::mapLocationFromPreamble ( SourceLocation  Loc)
SourceLocation ASTUnit::mapLocationToPreamble ( SourceLocation  Loc)
SourceRange clang::ASTUnit::mapRangeFromPreamble ( SourceRange  R) [inline]
SourceRange clang::ASTUnit::mapRangeToPreamble ( SourceRange  R) [inline]
bool ASTUnit::Reparse ( RemappedFile RemappedFiles = 0,
unsigned  NumRemappedFiles = 0 
)
CXSaveError ASTUnit::Save ( StringRef  File)

Save this translation unit to a file with the given name.

Returns:
An indication of whether the save was successful or not.

Definition at line 2426 of file ASTUnit.cpp.

References CXSaveError_None, CXSaveError_Unknown, and serialize().

bool ASTUnit::serialize ( raw_ostream &  OS)

Serialize this translation unit with the given output stream.

Returns:
True if an error occurred, false otherwise.

Definition at line 2457 of file ASTUnit.cpp.

References getDiagnostics(), getSema(), clang::DiagnosticsEngine::hasErrorOccurred(), and clang::ASTWriter::WriteAST().

Referenced by Save().

void clang::ASTUnit::setASTContext ( ASTContext ctx) [inline]

Definition at line 445 of file ASTUnit.h.

void clang::ASTUnit::setOwnsRemappedFileBuffers ( bool  val) [inline]

Definition at line 469 of file ASTUnit.h.

void ASTUnit::setPreprocessor ( Preprocessor pp)

Definition at line 258 of file ASTUnit.cpp.

void clang::ASTUnit::setUnsafeToFree ( bool  Value) [inline]

Definition at line 431 of file ASTUnit.h.

stored_diag_iterator clang::ASTUnit::stored_diag_afterDriver_begin ( ) [inline]

Definition at line 579 of file ASTUnit.h.

Referenced by CodeComplete().

stored_diag_const_iterator clang::ASTUnit::stored_diag_begin ( ) const [inline]

Definition at line 565 of file ASTUnit.h.

Referenced by CodeComplete().

stored_diag_iterator clang::ASTUnit::stored_diag_begin ( ) [inline]

Definition at line 568 of file ASTUnit.h.

stored_diag_const_iterator clang::ASTUnit::stored_diag_end ( ) const [inline]

Definition at line 571 of file ASTUnit.h.

stored_diag_iterator clang::ASTUnit::stored_diag_end ( ) [inline]

Definition at line 574 of file ASTUnit.h.

unsigned clang::ASTUnit::stored_diag_size ( ) const [inline]

Definition at line 577 of file ASTUnit.h.

top_level_iterator clang::ASTUnit::top_level_begin ( ) [inline]

Definition at line 475 of file ASTUnit.h.

References isMainFileAST().

bool clang::ASTUnit::top_level_empty ( ) const [inline]

Definition at line 494 of file ASTUnit.h.

References isMainFileAST().

top_level_iterator clang::ASTUnit::top_level_end ( ) [inline]

Definition at line 482 of file ASTUnit.h.

References isMainFileAST().

std::size_t clang::ASTUnit::top_level_size ( ) const [inline]

Definition at line 489 of file ASTUnit.h.

References isMainFileAST().


Friends And Related Function Documentation

friend class ConcurrencyCheck [friend]

Definition at line 424 of file ASTUnit.h.


The documentation for this class was generated from the following files: