ASTUnit.h revision 9b7db6200d366e4964d63ae1f33c7b9d7b9831cb
1//===--- ASTUnit.h - ASTUnit utility ----------------------------*- C++ -*-===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9// 10// ASTUnit utility class. 11// 12//===----------------------------------------------------------------------===// 13 14#ifndef LLVM_CLANG_FRONTEND_ASTUNIT_H 15#define LLVM_CLANG_FRONTEND_ASTUNIT_H 16 17#include "clang/Index/ASTLocation.h" 18#include "clang/Serialization/ASTBitCodes.h" 19#include "clang/Sema/Sema.h" 20#include "clang/Sema/CodeCompleteConsumer.h" 21#include "clang/Lex/PreprocessingRecord.h" 22#include "clang/Basic/SourceManager.h" 23#include "clang/Basic/FileManager.h" 24#include "clang/Basic/FileSystemOptions.h" 25#include "clang-c/Index.h" 26#include "llvm/ADT/IntrusiveRefCntPtr.h" 27#include "llvm/ADT/OwningPtr.h" 28#include "llvm/ADT/SmallVector.h" 29#include "llvm/ADT/StringMap.h" 30#include "llvm/Support/Path.h" 31#include <map> 32#include <string> 33#include <vector> 34#include <cassert> 35#include <utility> 36#include <sys/types.h> 37 38namespace llvm { 39 class MemoryBuffer; 40} 41 42namespace clang { 43class ASTContext; 44class CodeCompleteConsumer; 45class CompilerInvocation; 46class Decl; 47class Diagnostic; 48class FileEntry; 49class FileManager; 50class HeaderSearch; 51class Preprocessor; 52class SourceManager; 53class TargetInfo; 54 55using namespace idx; 56 57/// \brief Utility class for loading a ASTContext from an AST file. 58/// 59class ASTUnit { 60public: 61 typedef std::map<FileID, std::vector<PreprocessedEntity *> > 62 PreprocessedEntitiesByFileMap; 63 64private: 65 llvm::IntrusiveRefCntPtr<Diagnostic> Diagnostics; 66 llvm::OwningPtr<FileManager> FileMgr; 67 llvm::OwningPtr<SourceManager> SourceMgr; 68 llvm::OwningPtr<HeaderSearch> HeaderInfo; 69 llvm::OwningPtr<TargetInfo> Target; 70 llvm::OwningPtr<Preprocessor> PP; 71 llvm::OwningPtr<ASTContext> Ctx; 72 73 FileSystemOptions FileSystemOpts; 74 75 /// \brief The AST consumer that received information about the translation 76 /// unit as it was parsed or loaded. 77 llvm::OwningPtr<ASTConsumer> Consumer; 78 79 /// \brief The semantic analysis object used to type-check the translation 80 /// unit. 81 llvm::OwningPtr<Sema> TheSema; 82 83 /// Optional owned invocation, just used to make the invocation used in 84 /// LoadFromCommandLine available. 85 llvm::OwningPtr<CompilerInvocation> Invocation; 86 87 /// \brief The set of target features. 88 /// 89 /// FIXME: each time we reparse, we need to restore the set of target 90 /// features from this vector, because TargetInfo::CreateTargetInfo() 91 /// mangles the target options in place. Yuck! 92 std::vector<std::string> TargetFeatures; 93 94 // OnlyLocalDecls - when true, walking this AST should only visit declarations 95 // that come from the AST itself, not from included precompiled headers. 96 // FIXME: This is temporary; eventually, CIndex will always do this. 97 bool OnlyLocalDecls; 98 99 /// \brief Whether to capture any diagnostics produced. 100 bool CaptureDiagnostics; 101 102 /// \brief Track whether the main file was loaded from an AST or not. 103 bool MainFileIsAST; 104 105 /// \brief Whether this AST represents a complete translation unit. 106 bool CompleteTranslationUnit; 107 108 /// \brief Whether we should time each operation. 109 bool WantTiming; 110 111 /// Track the top-level decls which appeared in an ASTUnit which was loaded 112 /// from a source file. 113 // 114 // FIXME: This is just an optimization hack to avoid deserializing large parts 115 // of a PCH file when using the Index library on an ASTUnit loaded from 116 // source. In the long term we should make the Index library use efficient and 117 // more scalable search mechanisms. 118 std::vector<Decl*> TopLevelDecls; 119 120 /// \brief The list of preprocessed entities which appeared when the ASTUnit 121 /// was loaded. 122 /// 123 /// FIXME: This is just an optimization hack to avoid deserializing large 124 /// parts of a PCH file while performing a walk or search. In the long term, 125 /// we should provide more scalable search mechanisms. 126 std::vector<PreprocessedEntity *> PreprocessedEntities; 127 128 /// The name of the original source file used to generate this ASTUnit. 129 std::string OriginalSourceFile; 130 131 // Critical optimization when using clang_getCursor(). 132 ASTLocation LastLoc; 133 134 /// \brief The set of diagnostics produced when creating this 135 /// translation unit. 136 llvm::SmallVector<StoredDiagnostic, 4> StoredDiagnostics; 137 138 /// \brief The number of stored diagnostics that come from the driver 139 /// itself. 140 /// 141 /// Diagnostics that come from the driver are retained from one parse to 142 /// the next. 143 unsigned NumStoredDiagnosticsFromDriver; 144 145 /// \brief Temporary files that should be removed when the ASTUnit is 146 /// destroyed. 147 llvm::SmallVector<llvm::sys::Path, 4> TemporaryFiles; 148 149 /// \brief A mapping from file IDs to the set of preprocessed entities 150 /// stored in that file. 151 /// 152 /// FIXME: This is just an optimization hack to avoid searching through 153 /// many preprocessed entities during cursor traversal in the CIndex library. 154 /// Ideally, we would just be able to perform a binary search within the 155 /// list of preprocessed entities. 156 PreprocessedEntitiesByFileMap PreprocessedEntitiesByFile; 157 158 /// \brief Simple hack to allow us to assert that ASTUnit is not being 159 /// used concurrently, which is not supported. 160 /// 161 /// Clients should create instances of the ConcurrencyCheck class whenever 162 /// using the ASTUnit in a way that isn't intended to be concurrent, which is 163 /// just about any usage. 164 unsigned int ConcurrencyCheckValue; 165 static const unsigned int CheckLocked = 28573289; 166 static const unsigned int CheckUnlocked = 9803453; 167 168 /// \brief Counter that determines when we want to try building a 169 /// precompiled preamble. 170 /// 171 /// If zero, we will never build a precompiled preamble. Otherwise, 172 /// it's treated as a counter that decrements each time we reparse 173 /// without the benefit of a precompiled preamble. When it hits 1, 174 /// we'll attempt to rebuild the precompiled header. This way, if 175 /// building the precompiled preamble fails, we won't try again for 176 /// some number of calls. 177 unsigned PreambleRebuildCounter; 178 179 /// \brief The file in which the precompiled preamble is stored. 180 std::string PreambleFile; 181 182 /// \brief The contents of the preamble that has been precompiled to 183 /// \c PreambleFile. 184 std::vector<char> Preamble; 185 186 /// \brief Whether the preamble ends at the start of a new line. 187 /// 188 /// Used to inform the lexer as to whether it's starting at the beginning of 189 /// a line after skipping the preamble. 190 bool PreambleEndsAtStartOfLine; 191 192 /// \brief The size of the source buffer that we've reserved for the main 193 /// file within the precompiled preamble. 194 unsigned PreambleReservedSize; 195 196 /// \brief Keeps track of the files that were used when computing the 197 /// preamble, with both their buffer size and their modification time. 198 /// 199 /// If any of the files have changed from one compile to the next, 200 /// the preamble must be thrown away. 201 llvm::StringMap<std::pair<off_t, time_t> > FilesInPreamble; 202 203 /// \brief When non-NULL, this is the buffer used to store the contents of 204 /// the main file when it has been padded for use with the precompiled 205 /// preamble. 206 llvm::MemoryBuffer *SavedMainFileBuffer; 207 208 /// \brief When non-NULL, this is the buffer used to store the 209 /// contents of the preamble when it has been padded to build the 210 /// precompiled preamble. 211 llvm::MemoryBuffer *PreambleBuffer; 212 213 /// \brief The number of warnings that occurred while parsing the preamble. 214 /// 215 /// This value will be used to restore the state of the \c Diagnostic object 216 /// when re-using the precompiled preamble. Note that only the 217 /// number of warnings matters, since we will not save the preamble 218 /// when any errors are present. 219 unsigned NumWarningsInPreamble; 220 221 /// \brief The number of diagnostics that were stored when parsing 222 /// the precompiled preamble. 223 /// 224 /// This value is used to determine how many of the stored 225 /// diagnostics should be retained when reparsing in the presence of 226 /// a precompiled preamble. 227 unsigned NumStoredDiagnosticsInPreamble; 228 229 /// \brief A list of the serialization ID numbers for each of the top-level 230 /// declarations parsed within the precompiled preamble. 231 std::vector<serialization::DeclID> TopLevelDeclsInPreamble; 232 233 /// \brief A list of the offsets into the precompiled preamble which 234 /// correspond to preprocessed entities. 235 std::vector<uint64_t> PreprocessedEntitiesInPreamble; 236 237 /// \brief Whether we should be caching code-completion results. 238 bool ShouldCacheCodeCompletionResults; 239 240 static void ConfigureDiags(llvm::IntrusiveRefCntPtr<Diagnostic> &Diags, 241 const char **ArgBegin, const char **ArgEnd, 242 ASTUnit &AST, bool CaptureDiagnostics); 243 244public: 245 /// \brief A cached code-completion result, which may be introduced in one of 246 /// many different contexts. 247 struct CachedCodeCompletionResult { 248 /// \brief The code-completion string corresponding to this completion 249 /// result. 250 CodeCompletionString *Completion; 251 252 /// \brief A bitmask that indicates which code-completion contexts should 253 /// contain this completion result. 254 /// 255 /// The bits in the bitmask correspond to the values of 256 /// CodeCompleteContext::Kind. To map from a completion context kind to a 257 /// bit, subtract one from the completion context kind and shift 1 by that 258 /// number of bits. Many completions can occur in several different 259 /// contexts. 260 unsigned ShowInContexts; 261 262 /// \brief The priority given to this code-completion result. 263 unsigned Priority; 264 265 /// \brief The libclang cursor kind corresponding to this code-completion 266 /// result. 267 CXCursorKind Kind; 268 269 /// \brief The availability of this code-completion result. 270 CXAvailabilityKind Availability; 271 272 /// \brief The simplified type class for a non-macro completion result. 273 SimplifiedTypeClass TypeClass; 274 275 /// \brief The type of a non-macro completion result, stored as a unique 276 /// integer used by the string map of cached completion types. 277 /// 278 /// This value will be zero if the type is not known, or a unique value 279 /// determined by the formatted type string. Se \c CachedCompletionTypes 280 /// for more information. 281 unsigned Type; 282 }; 283 284 /// \brief Retrieve the mapping from formatted type names to unique type 285 /// identifiers. 286 llvm::StringMap<unsigned> &getCachedCompletionTypes() { 287 return CachedCompletionTypes; 288 } 289 290private: 291 /// \brief Allocator used to store cached code completions. 292 CodeCompletionAllocator CachedCompletionAllocator; 293 294 /// \brief The set of cached code-completion results. 295 std::vector<CachedCodeCompletionResult> CachedCompletionResults; 296 297 /// \brief A mapping from the formatted type name to a unique number for that 298 /// type, which is used for type equality comparisons. 299 llvm::StringMap<unsigned> CachedCompletionTypes; 300 301 /// \brief A string hash of the top-level declaration and macro definition 302 /// names processed the last time that we reparsed the file. 303 /// 304 /// This hash value is used to determine when we need to refresh the 305 /// global code-completion cache. 306 unsigned CompletionCacheTopLevelHashValue; 307 308 /// \brief A string hash of the top-level declaration and macro definition 309 /// names processed the last time that we reparsed the precompiled preamble. 310 /// 311 /// This hash value is used to determine when we need to refresh the 312 /// global code-completion cache after a rebuild of the precompiled preamble. 313 unsigned PreambleTopLevelHashValue; 314 315 /// \brief The current hash value for the top-level declaration and macro 316 /// definition names 317 unsigned CurrentTopLevelHashValue; 318 319 /// \brief Bit used by CIndex to mark when a translation unit may be in an 320 /// inconsistent state, and is not safe to free. 321 unsigned UnsafeToFree : 1; 322 323 /// \brief Cache any "global" code-completion results, so that we can avoid 324 /// recomputing them with each completion. 325 void CacheCodeCompletionResults(); 326 327 /// \brief Clear out and deallocate 328 void ClearCachedCompletionResults(); 329 330 ASTUnit(const ASTUnit&); // DO NOT IMPLEMENT 331 ASTUnit &operator=(const ASTUnit &); // DO NOT IMPLEMENT 332 333 explicit ASTUnit(bool MainFileIsAST); 334 335 void CleanTemporaryFiles(); 336 bool Parse(llvm::MemoryBuffer *OverrideMainBuffer); 337 338 std::pair<llvm::MemoryBuffer *, std::pair<unsigned, bool> > 339 ComputePreamble(CompilerInvocation &Invocation, 340 unsigned MaxLines, bool &CreatedBuffer); 341 342 llvm::MemoryBuffer *getMainBufferWithPrecompiledPreamble( 343 CompilerInvocation PreambleInvocation, 344 bool AllowRebuild = true, 345 unsigned MaxLines = 0); 346 void RealizeTopLevelDeclsFromPreamble(); 347 void RealizePreprocessedEntitiesFromPreamble(); 348 349public: 350 class ConcurrencyCheck { 351 volatile ASTUnit &Self; 352 353 public: 354 explicit ConcurrencyCheck(ASTUnit &Self) 355 : Self(Self) 356 { 357 assert(Self.ConcurrencyCheckValue == CheckUnlocked && 358 "Concurrent access to ASTUnit!"); 359 Self.ConcurrencyCheckValue = CheckLocked; 360 } 361 362 ~ConcurrencyCheck() { 363 Self.ConcurrencyCheckValue = CheckUnlocked; 364 } 365 }; 366 friend class ConcurrencyCheck; 367 368 ~ASTUnit(); 369 370 bool isMainFileAST() const { return MainFileIsAST; } 371 372 bool isUnsafeToFree() const { return UnsafeToFree; } 373 void setUnsafeToFree(bool Value) { UnsafeToFree = Value; } 374 375 const Diagnostic &getDiagnostics() const { return *Diagnostics; } 376 Diagnostic &getDiagnostics() { return *Diagnostics; } 377 378 const SourceManager &getSourceManager() const { return *SourceMgr; } 379 SourceManager &getSourceManager() { return *SourceMgr; } 380 381 const Preprocessor &getPreprocessor() const { return *PP.get(); } 382 Preprocessor &getPreprocessor() { return *PP.get(); } 383 384 const ASTContext &getASTContext() const { return *Ctx.get(); } 385 ASTContext &getASTContext() { return *Ctx.get(); } 386 387 bool hasSema() const { return TheSema; } 388 Sema &getSema() const { 389 assert(TheSema && "ASTUnit does not have a Sema object!"); 390 return *TheSema; 391 } 392 393 const FileManager &getFileManager() const { return *FileMgr; } 394 FileManager &getFileManager() { return *FileMgr; } 395 396 const FileSystemOptions &getFileSystemOpts() const { return FileSystemOpts; } 397 398 const std::string &getOriginalSourceFileName(); 399 const std::string &getASTFileName(); 400 401 /// \brief Add a temporary file that the ASTUnit depends on. 402 /// 403 /// This file will be erased when the ASTUnit is destroyed. 404 void addTemporaryFile(const llvm::sys::Path &TempFile) { 405 TemporaryFiles.push_back(TempFile); 406 } 407 408 bool getOnlyLocalDecls() const { return OnlyLocalDecls; } 409 410 /// \brief Retrieve the maximum PCH level of declarations that a 411 /// traversal of the translation unit should consider. 412 unsigned getMaxPCHLevel() const; 413 414 void setLastASTLocation(ASTLocation ALoc) { LastLoc = ALoc; } 415 ASTLocation getLastASTLocation() const { return LastLoc; } 416 417 418 llvm::StringRef getMainFileName() const; 419 420 typedef std::vector<Decl *>::iterator top_level_iterator; 421 422 top_level_iterator top_level_begin() { 423 assert(!isMainFileAST() && "Invalid call for AST based ASTUnit!"); 424 if (!TopLevelDeclsInPreamble.empty()) 425 RealizeTopLevelDeclsFromPreamble(); 426 return TopLevelDecls.begin(); 427 } 428 429 top_level_iterator top_level_end() { 430 assert(!isMainFileAST() && "Invalid call for AST based ASTUnit!"); 431 if (!TopLevelDeclsInPreamble.empty()) 432 RealizeTopLevelDeclsFromPreamble(); 433 return TopLevelDecls.end(); 434 } 435 436 std::size_t top_level_size() const { 437 assert(!isMainFileAST() && "Invalid call for AST based ASTUnit!"); 438 return TopLevelDeclsInPreamble.size() + TopLevelDecls.size(); 439 } 440 441 bool top_level_empty() const { 442 assert(!isMainFileAST() && "Invalid call for AST based ASTUnit!"); 443 return TopLevelDeclsInPreamble.empty() && TopLevelDecls.empty(); 444 } 445 446 /// \brief Add a new top-level declaration. 447 void addTopLevelDecl(Decl *D) { 448 TopLevelDecls.push_back(D); 449 } 450 451 /// \brief Add a new top-level declaration, identified by its ID in 452 /// the precompiled preamble. 453 void addTopLevelDeclFromPreamble(serialization::DeclID D) { 454 TopLevelDeclsInPreamble.push_back(D); 455 } 456 457 /// \brief Retrieve a reference to the current top-level name hash value. 458 /// 459 /// Note: This is used internally by the top-level tracking action 460 unsigned &getCurrentTopLevelHashValue() { return CurrentTopLevelHashValue; } 461 462 typedef std::vector<PreprocessedEntity *>::iterator pp_entity_iterator; 463 464 pp_entity_iterator pp_entity_begin(); 465 pp_entity_iterator pp_entity_end(); 466 467 /// \brief Add a new preprocessed entity that's stored at the given offset 468 /// in the precompiled preamble. 469 void addPreprocessedEntityFromPreamble(uint64_t Offset) { 470 PreprocessedEntitiesInPreamble.push_back(Offset); 471 } 472 473 /// \brief Retrieve the mapping from File IDs to the preprocessed entities 474 /// within that file. 475 PreprocessedEntitiesByFileMap &getPreprocessedEntitiesByFile() { 476 return PreprocessedEntitiesByFile; 477 } 478 479 // Retrieve the diagnostics associated with this AST 480 typedef const StoredDiagnostic *stored_diag_iterator; 481 stored_diag_iterator stored_diag_begin() const { 482 return StoredDiagnostics.begin(); 483 } 484 stored_diag_iterator stored_diag_end() const { 485 return StoredDiagnostics.end(); 486 } 487 unsigned stored_diag_size() const { return StoredDiagnostics.size(); } 488 489 llvm::SmallVector<StoredDiagnostic, 4> &getStoredDiagnostics() { 490 return StoredDiagnostics; 491 } 492 493 typedef std::vector<CachedCodeCompletionResult>::iterator 494 cached_completion_iterator; 495 496 cached_completion_iterator cached_completion_begin() { 497 return CachedCompletionResults.begin(); 498 } 499 500 cached_completion_iterator cached_completion_end() { 501 return CachedCompletionResults.end(); 502 } 503 504 unsigned cached_completion_size() const { 505 return CachedCompletionResults.size(); 506 } 507 508 llvm::MemoryBuffer *getBufferForFile(llvm::StringRef Filename, 509 std::string *ErrorStr = 0); 510 511 /// \brief Whether this AST represents a complete translation unit. 512 /// 513 /// If false, this AST is only a partial translation unit, e.g., one 514 /// that might still be used as a precompiled header or preamble. 515 bool isCompleteTranslationUnit() const { return CompleteTranslationUnit; } 516 517 /// \brief A mapping from a file name to the memory buffer that stores the 518 /// remapped contents of that file. 519 typedef std::pair<std::string, const llvm::MemoryBuffer *> RemappedFile; 520 521 /// \brief Create a ASTUnit from an AST file. 522 /// 523 /// \param Filename - The AST file to load. 524 /// 525 /// \param Diags - The diagnostics engine to use for reporting errors; its 526 /// lifetime is expected to extend past that of the returned ASTUnit. 527 /// 528 /// \returns - The initialized ASTUnit or null if the AST failed to load. 529 static ASTUnit *LoadFromASTFile(const std::string &Filename, 530 llvm::IntrusiveRefCntPtr<Diagnostic> Diags, 531 const FileSystemOptions &FileSystemOpts, 532 bool OnlyLocalDecls = false, 533 RemappedFile *RemappedFiles = 0, 534 unsigned NumRemappedFiles = 0, 535 bool CaptureDiagnostics = false); 536 537private: 538 /// \brief Helper function for \c LoadFromCompilerInvocation() and 539 /// \c LoadFromCommandLine(), which loads an AST from a compiler invocation. 540 /// 541 /// \param PrecompilePreamble Whether to precompile the preamble of this 542 /// translation unit, to improve the performance of reparsing. 543 /// 544 /// \returns \c true if a catastrophic failure occurred (which means that the 545 /// \c ASTUnit itself is invalid), or \c false otherwise. 546 bool LoadFromCompilerInvocation(bool PrecompilePreamble); 547 548public: 549 550 /// LoadFromCompilerInvocation - Create an ASTUnit from a source file, via a 551 /// CompilerInvocation object. 552 /// 553 /// \param CI - The compiler invocation to use; it must have exactly one input 554 /// source file. The ASTUnit takes ownership of the CompilerInvocation object. 555 /// 556 /// \param Diags - The diagnostics engine to use for reporting errors; its 557 /// lifetime is expected to extend past that of the returned ASTUnit. 558 // 559 // FIXME: Move OnlyLocalDecls, UseBumpAllocator to setters on the ASTUnit, we 560 // shouldn't need to specify them at construction time. 561 static ASTUnit *LoadFromCompilerInvocation(CompilerInvocation *CI, 562 llvm::IntrusiveRefCntPtr<Diagnostic> Diags, 563 bool OnlyLocalDecls = false, 564 bool CaptureDiagnostics = false, 565 bool PrecompilePreamble = false, 566 bool CompleteTranslationUnit = true, 567 bool CacheCodeCompletionResults = false); 568 569 /// LoadFromCommandLine - Create an ASTUnit from a vector of command line 570 /// arguments, which must specify exactly one source file. 571 /// 572 /// \param ArgBegin - The beginning of the argument vector. 573 /// 574 /// \param ArgEnd - The end of the argument vector. 575 /// 576 /// \param Diags - The diagnostics engine to use for reporting errors; its 577 /// lifetime is expected to extend past that of the returned ASTUnit. 578 /// 579 /// \param ResourceFilesPath - The path to the compiler resource files. 580 // 581 // FIXME: Move OnlyLocalDecls, UseBumpAllocator to setters on the ASTUnit, we 582 // shouldn't need to specify them at construction time. 583 static ASTUnit *LoadFromCommandLine(const char **ArgBegin, 584 const char **ArgEnd, 585 llvm::IntrusiveRefCntPtr<Diagnostic> Diags, 586 llvm::StringRef ResourceFilesPath, 587 bool OnlyLocalDecls = false, 588 bool CaptureDiagnostics = false, 589 RemappedFile *RemappedFiles = 0, 590 unsigned NumRemappedFiles = 0, 591 bool PrecompilePreamble = false, 592 bool CompleteTranslationUnit = true, 593 bool CacheCodeCompletionResults = false, 594 bool CXXPrecompilePreamble = false, 595 bool CXXChainedPCH = false); 596 597 /// \brief Reparse the source files using the same command-line options that 598 /// were originally used to produce this translation unit. 599 /// 600 /// \returns True if a failure occurred that causes the ASTUnit not to 601 /// contain any translation-unit information, false otherwise. 602 bool Reparse(RemappedFile *RemappedFiles = 0, 603 unsigned NumRemappedFiles = 0); 604 605 /// \brief Perform code completion at the given file, line, and 606 /// column within this translation unit. 607 /// 608 /// \param File The file in which code completion will occur. 609 /// 610 /// \param Line The line at which code completion will occur. 611 /// 612 /// \param Column The column at which code completion will occur. 613 /// 614 /// \param IncludeMacros Whether to include macros in the code-completion 615 /// results. 616 /// 617 /// \param IncludeCodePatterns Whether to include code patterns (such as a 618 /// for loop) in the code-completion results. 619 /// 620 /// FIXME: The Diag, LangOpts, SourceMgr, FileMgr, StoredDiagnostics, and 621 /// OwnedBuffers parameters are all disgusting hacks. They will go away. 622 void CodeComplete(llvm::StringRef File, unsigned Line, unsigned Column, 623 RemappedFile *RemappedFiles, unsigned NumRemappedFiles, 624 bool IncludeMacros, bool IncludeCodePatterns, 625 CodeCompleteConsumer &Consumer, 626 Diagnostic &Diag, LangOptions &LangOpts, 627 SourceManager &SourceMgr, FileManager &FileMgr, 628 llvm::SmallVectorImpl<StoredDiagnostic> &StoredDiagnostics, 629 llvm::SmallVectorImpl<const llvm::MemoryBuffer *> &OwnedBuffers); 630 631 /// \brief Save this translation unit to a file with the given name. 632 /// 633 /// \returns True if an error occurred, false otherwise. 634 bool Save(llvm::StringRef File); 635}; 636 637} // namespace clang 638 639#endif 640