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