ASTUnit.h revision dae687575010c9c49a4b552f5eef82cd6279d9ac
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 The number of top-level declarations present the last time we
302  /// cached code-completion results.
303  ///
304  /// The value is used to help detect when we should repopulate the global
305  /// completion cache.
306  unsigned NumTopLevelDeclsAtLastCompletionCache;
307
308  /// \brief The number of reparses left until we'll consider updating the
309  /// code-completion cache.
310  ///
311  /// This is meant to avoid thrashing during reparsing, by not allowing the
312  /// code-completion cache to be updated on every reparse.
313  unsigned CacheCodeCompletionCoolDown;
314
315  /// \brief Bit used by CIndex to mark when a translation unit may be in an
316  /// inconsistent state, and is not safe to free.
317  unsigned UnsafeToFree : 1;
318
319  /// \brief Cache any "global" code-completion results, so that we can avoid
320  /// recomputing them with each completion.
321  void CacheCodeCompletionResults();
322
323  /// \brief Clear out and deallocate
324  void ClearCachedCompletionResults();
325
326  ASTUnit(const ASTUnit&); // DO NOT IMPLEMENT
327  ASTUnit &operator=(const ASTUnit &); // DO NOT IMPLEMENT
328
329  explicit ASTUnit(bool MainFileIsAST);
330
331  void CleanTemporaryFiles();
332  bool Parse(llvm::MemoryBuffer *OverrideMainBuffer);
333
334  std::pair<llvm::MemoryBuffer *, std::pair<unsigned, bool> >
335  ComputePreamble(CompilerInvocation &Invocation,
336                  unsigned MaxLines, bool &CreatedBuffer);
337
338  llvm::MemoryBuffer *getMainBufferWithPrecompiledPreamble(
339                                         CompilerInvocation PreambleInvocation,
340                                                     bool AllowRebuild = true,
341                                                        unsigned MaxLines = 0);
342  void RealizeTopLevelDeclsFromPreamble();
343  void RealizePreprocessedEntitiesFromPreamble();
344
345public:
346  class ConcurrencyCheck {
347    volatile ASTUnit &Self;
348
349  public:
350    explicit ConcurrencyCheck(ASTUnit &Self)
351      : Self(Self)
352    {
353      assert(Self.ConcurrencyCheckValue == CheckUnlocked &&
354             "Concurrent access to ASTUnit!");
355      Self.ConcurrencyCheckValue = CheckLocked;
356    }
357
358    ~ConcurrencyCheck() {
359      Self.ConcurrencyCheckValue = CheckUnlocked;
360    }
361  };
362  friend class ConcurrencyCheck;
363
364  ~ASTUnit();
365
366  bool isMainFileAST() const { return MainFileIsAST; }
367
368  bool isUnsafeToFree() const { return UnsafeToFree; }
369  void setUnsafeToFree(bool Value) { UnsafeToFree = Value; }
370
371  const Diagnostic &getDiagnostics() const { return *Diagnostics; }
372  Diagnostic &getDiagnostics()             { return *Diagnostics; }
373
374  const SourceManager &getSourceManager() const { return *SourceMgr; }
375        SourceManager &getSourceManager()       { return *SourceMgr; }
376
377  const Preprocessor &getPreprocessor() const { return *PP.get(); }
378        Preprocessor &getPreprocessor()       { return *PP.get(); }
379
380  const ASTContext &getASTContext() const { return *Ctx.get(); }
381        ASTContext &getASTContext()       { return *Ctx.get(); }
382
383  bool hasSema() const { return TheSema; }
384  Sema &getSema() const {
385    assert(TheSema && "ASTUnit does not have a Sema object!");
386    return *TheSema;
387  }
388
389  const FileManager &getFileManager() const { return *FileMgr; }
390        FileManager &getFileManager()       { return *FileMgr; }
391
392  const FileSystemOptions &getFileSystemOpts() const { return FileSystemOpts; }
393
394  const std::string &getOriginalSourceFileName();
395  const std::string &getASTFileName();
396
397  /// \brief Add a temporary file that the ASTUnit depends on.
398  ///
399  /// This file will be erased when the ASTUnit is destroyed.
400  void addTemporaryFile(const llvm::sys::Path &TempFile) {
401    TemporaryFiles.push_back(TempFile);
402  }
403
404  bool getOnlyLocalDecls() const { return OnlyLocalDecls; }
405
406  /// \brief Retrieve the maximum PCH level of declarations that a
407  /// traversal of the translation unit should consider.
408  unsigned getMaxPCHLevel() const;
409
410  void setLastASTLocation(ASTLocation ALoc) { LastLoc = ALoc; }
411  ASTLocation getLastASTLocation() const { return LastLoc; }
412
413
414  llvm::StringRef getMainFileName() const;
415
416  typedef std::vector<Decl *>::iterator top_level_iterator;
417
418  top_level_iterator top_level_begin() {
419    assert(!isMainFileAST() && "Invalid call for AST based ASTUnit!");
420    if (!TopLevelDeclsInPreamble.empty())
421      RealizeTopLevelDeclsFromPreamble();
422    return TopLevelDecls.begin();
423  }
424
425  top_level_iterator top_level_end() {
426    assert(!isMainFileAST() && "Invalid call for AST based ASTUnit!");
427    if (!TopLevelDeclsInPreamble.empty())
428      RealizeTopLevelDeclsFromPreamble();
429    return TopLevelDecls.end();
430  }
431
432  std::size_t top_level_size() const {
433    assert(!isMainFileAST() && "Invalid call for AST based ASTUnit!");
434    return TopLevelDeclsInPreamble.size() + TopLevelDecls.size();
435  }
436
437  bool top_level_empty() const {
438    assert(!isMainFileAST() && "Invalid call for AST based ASTUnit!");
439    return TopLevelDeclsInPreamble.empty() && TopLevelDecls.empty();
440  }
441
442  /// \brief Add a new top-level declaration.
443  void addTopLevelDecl(Decl *D) {
444    TopLevelDecls.push_back(D);
445  }
446
447  /// \brief Add a new top-level declaration, identified by its ID in
448  /// the precompiled preamble.
449  void addTopLevelDeclFromPreamble(serialization::DeclID D) {
450    TopLevelDeclsInPreamble.push_back(D);
451  }
452
453  typedef std::vector<PreprocessedEntity *>::iterator pp_entity_iterator;
454
455  pp_entity_iterator pp_entity_begin();
456  pp_entity_iterator pp_entity_end();
457
458  /// \brief Add a new preprocessed entity that's stored at the given offset
459  /// in the precompiled preamble.
460  void addPreprocessedEntityFromPreamble(uint64_t Offset) {
461    PreprocessedEntitiesInPreamble.push_back(Offset);
462  }
463
464  /// \brief Retrieve the mapping from File IDs to the preprocessed entities
465  /// within that file.
466  PreprocessedEntitiesByFileMap &getPreprocessedEntitiesByFile() {
467    return PreprocessedEntitiesByFile;
468  }
469
470  // Retrieve the diagnostics associated with this AST
471  typedef const StoredDiagnostic *stored_diag_iterator;
472  stored_diag_iterator stored_diag_begin() const {
473    return StoredDiagnostics.begin();
474  }
475  stored_diag_iterator stored_diag_end() const {
476    return StoredDiagnostics.end();
477  }
478  unsigned stored_diag_size() const { return StoredDiagnostics.size(); }
479
480  llvm::SmallVector<StoredDiagnostic, 4> &getStoredDiagnostics() {
481    return StoredDiagnostics;
482  }
483
484  typedef std::vector<CachedCodeCompletionResult>::iterator
485    cached_completion_iterator;
486
487  cached_completion_iterator cached_completion_begin() {
488    return CachedCompletionResults.begin();
489  }
490
491  cached_completion_iterator cached_completion_end() {
492    return CachedCompletionResults.end();
493  }
494
495  unsigned cached_completion_size() const {
496    return CachedCompletionResults.size();
497  }
498
499  llvm::MemoryBuffer *getBufferForFile(llvm::StringRef Filename,
500                                       std::string *ErrorStr = 0);
501
502  /// \brief Whether this AST represents a complete translation unit.
503  ///
504  /// If false, this AST is only a partial translation unit, e.g., one
505  /// that might still be used as a precompiled header or preamble.
506  bool isCompleteTranslationUnit() const { return CompleteTranslationUnit; }
507
508  /// \brief A mapping from a file name to the memory buffer that stores the
509  /// remapped contents of that file.
510  typedef std::pair<std::string, const llvm::MemoryBuffer *> RemappedFile;
511
512  /// \brief Create a ASTUnit from an AST file.
513  ///
514  /// \param Filename - The AST file to load.
515  ///
516  /// \param Diags - The diagnostics engine to use for reporting errors; its
517  /// lifetime is expected to extend past that of the returned ASTUnit.
518  ///
519  /// \returns - The initialized ASTUnit or null if the AST failed to load.
520  static ASTUnit *LoadFromASTFile(const std::string &Filename,
521                                  llvm::IntrusiveRefCntPtr<Diagnostic> Diags,
522                                  const FileSystemOptions &FileSystemOpts,
523                                  bool OnlyLocalDecls = false,
524                                  RemappedFile *RemappedFiles = 0,
525                                  unsigned NumRemappedFiles = 0,
526                                  bool CaptureDiagnostics = false);
527
528private:
529  /// \brief Helper function for \c LoadFromCompilerInvocation() and
530  /// \c LoadFromCommandLine(), which loads an AST from a compiler invocation.
531  ///
532  /// \param PrecompilePreamble Whether to precompile the preamble of this
533  /// translation unit, to improve the performance of reparsing.
534  ///
535  /// \returns \c true if a catastrophic failure occurred (which means that the
536  /// \c ASTUnit itself is invalid), or \c false otherwise.
537  bool LoadFromCompilerInvocation(bool PrecompilePreamble);
538
539public:
540
541  /// LoadFromCompilerInvocation - Create an ASTUnit from a source file, via a
542  /// CompilerInvocation object.
543  ///
544  /// \param CI - The compiler invocation to use; it must have exactly one input
545  /// source file. The ASTUnit takes ownership of the CompilerInvocation object.
546  ///
547  /// \param Diags - The diagnostics engine to use for reporting errors; its
548  /// lifetime is expected to extend past that of the returned ASTUnit.
549  //
550  // FIXME: Move OnlyLocalDecls, UseBumpAllocator to setters on the ASTUnit, we
551  // shouldn't need to specify them at construction time.
552  static ASTUnit *LoadFromCompilerInvocation(CompilerInvocation *CI,
553                                     llvm::IntrusiveRefCntPtr<Diagnostic> Diags,
554                                             bool OnlyLocalDecls = false,
555                                             bool CaptureDiagnostics = false,
556                                             bool PrecompilePreamble = false,
557                                          bool CompleteTranslationUnit = true,
558                                       bool CacheCodeCompletionResults = false);
559
560  /// LoadFromCommandLine - Create an ASTUnit from a vector of command line
561  /// arguments, which must specify exactly one source file.
562  ///
563  /// \param ArgBegin - The beginning of the argument vector.
564  ///
565  /// \param ArgEnd - The end of the argument vector.
566  ///
567  /// \param Diags - The diagnostics engine to use for reporting errors; its
568  /// lifetime is expected to extend past that of the returned ASTUnit.
569  ///
570  /// \param ResourceFilesPath - The path to the compiler resource files.
571  //
572  // FIXME: Move OnlyLocalDecls, UseBumpAllocator to setters on the ASTUnit, we
573  // shouldn't need to specify them at construction time.
574  static ASTUnit *LoadFromCommandLine(const char **ArgBegin,
575                                      const char **ArgEnd,
576                                    llvm::IntrusiveRefCntPtr<Diagnostic> Diags,
577                                      llvm::StringRef ResourceFilesPath,
578                                      bool OnlyLocalDecls = false,
579                                      bool CaptureDiagnostics = false,
580                                      RemappedFile *RemappedFiles = 0,
581                                      unsigned NumRemappedFiles = 0,
582                                      bool PrecompilePreamble = false,
583                                      bool CompleteTranslationUnit = true,
584                                      bool CacheCodeCompletionResults = false,
585                                      bool CXXPrecompilePreamble = false,
586                                      bool CXXChainedPCH = false);
587
588  /// \brief Reparse the source files using the same command-line options that
589  /// were originally used to produce this translation unit.
590  ///
591  /// \returns True if a failure occurred that causes the ASTUnit not to
592  /// contain any translation-unit information, false otherwise.
593  bool Reparse(RemappedFile *RemappedFiles = 0,
594               unsigned NumRemappedFiles = 0);
595
596  /// \brief Perform code completion at the given file, line, and
597  /// column within this translation unit.
598  ///
599  /// \param File The file in which code completion will occur.
600  ///
601  /// \param Line The line at which code completion will occur.
602  ///
603  /// \param Column The column at which code completion will occur.
604  ///
605  /// \param IncludeMacros Whether to include macros in the code-completion
606  /// results.
607  ///
608  /// \param IncludeCodePatterns Whether to include code patterns (such as a
609  /// for loop) in the code-completion results.
610  ///
611  /// FIXME: The Diag, LangOpts, SourceMgr, FileMgr, StoredDiagnostics, and
612  /// OwnedBuffers parameters are all disgusting hacks. They will go away.
613  void CodeComplete(llvm::StringRef File, unsigned Line, unsigned Column,
614                    RemappedFile *RemappedFiles, unsigned NumRemappedFiles,
615                    bool IncludeMacros, bool IncludeCodePatterns,
616                    CodeCompleteConsumer &Consumer,
617                    Diagnostic &Diag, LangOptions &LangOpts,
618                    SourceManager &SourceMgr, FileManager &FileMgr,
619                    llvm::SmallVectorImpl<StoredDiagnostic> &StoredDiagnostics,
620              llvm::SmallVectorImpl<const llvm::MemoryBuffer *> &OwnedBuffers);
621
622  /// \brief Save this translation unit to a file with the given name.
623  ///
624  /// \returns True if an error occurred, false otherwise.
625  bool Save(llvm::StringRef File);
626};
627
628} // namespace clang
629
630#endif
631