ASTUnit.h revision 4ae8f298b1ea51b4c2234f9148e2e4349c9bdd23
14b562cf889bc59e1914dd2c5d9fbd7e7bfa1ad77Argyrios Kyrtzidis//===--- ASTUnit.h - ASTUnit utility ----------------------------*- C++ -*-===// 24b562cf889bc59e1914dd2c5d9fbd7e7bfa1ad77Argyrios Kyrtzidis// 34b562cf889bc59e1914dd2c5d9fbd7e7bfa1ad77Argyrios Kyrtzidis// The LLVM Compiler Infrastructure 44b562cf889bc59e1914dd2c5d9fbd7e7bfa1ad77Argyrios Kyrtzidis// 54b562cf889bc59e1914dd2c5d9fbd7e7bfa1ad77Argyrios Kyrtzidis// This file is distributed under the University of Illinois Open Source 64b562cf889bc59e1914dd2c5d9fbd7e7bfa1ad77Argyrios Kyrtzidis// License. See LICENSE.TXT for details. 74b562cf889bc59e1914dd2c5d9fbd7e7bfa1ad77Argyrios Kyrtzidis// 84b562cf889bc59e1914dd2c5d9fbd7e7bfa1ad77Argyrios Kyrtzidis//===----------------------------------------------------------------------===// 94b562cf889bc59e1914dd2c5d9fbd7e7bfa1ad77Argyrios Kyrtzidis// 104b562cf889bc59e1914dd2c5d9fbd7e7bfa1ad77Argyrios Kyrtzidis// ASTUnit utility class. 114b562cf889bc59e1914dd2c5d9fbd7e7bfa1ad77Argyrios Kyrtzidis// 124b562cf889bc59e1914dd2c5d9fbd7e7bfa1ad77Argyrios Kyrtzidis//===----------------------------------------------------------------------===// 134b562cf889bc59e1914dd2c5d9fbd7e7bfa1ad77Argyrios Kyrtzidis 140853a02c3b04d96a3c432b883e403175c954cd81Argyrios Kyrtzidis#ifndef LLVM_CLANG_FRONTEND_ASTUNIT_H 150853a02c3b04d96a3c432b883e403175c954cd81Argyrios Kyrtzidis#define LLVM_CLANG_FRONTEND_ASTUNIT_H 160853a02c3b04d96a3c432b883e403175c954cd81Argyrios Kyrtzidis 174ae8f298b1ea51b4c2234f9148e2e4349c9bdd23Douglas Gregor#include "clang/Lex/PreprocessingRecord.h" 1831b87d8006d4863dd9b17e515ac720941efc38e3Daniel Dunbar#include "clang/Basic/SourceManager.h" 190853a02c3b04d96a3c432b883e403175c954cd81Argyrios Kyrtzidis#include "llvm/ADT/OwningPtr.h" 2036c4464ba6cfc2a63dc67c493ef2f5ab2aea09ccSteve Naroff#include "clang/Basic/FileManager.h" 21f96b524306ccfa623235d375deee79637bd38f29Steve Naroff#include "clang/Index/ASTLocation.h" 22a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas Gregor#include "llvm/ADT/SmallVector.h" 23313e26c4e81f0e467490a530548450f4c824a6c4Douglas Gregor#include "llvm/System/Path.h" 240853a02c3b04d96a3c432b883e403175c954cd81Argyrios Kyrtzidis#include <string> 25f772d1e2a5688572d07f42896a50ac57a4a41fe8Daniel Dunbar#include <vector> 26f772d1e2a5688572d07f42896a50ac57a4a41fe8Daniel Dunbar#include <cassert> 274db64a461cb3442934afe43c83ed3f17f7c11c1dDouglas Gregor#include <utility> 284db64a461cb3442934afe43c83ed3f17f7c11c1dDouglas Gregor 294db64a461cb3442934afe43c83ed3f17f7c11c1dDouglas Gregornamespace llvm { 304db64a461cb3442934afe43c83ed3f17f7c11c1dDouglas Gregor class MemoryBuffer; 314db64a461cb3442934afe43c83ed3f17f7c11c1dDouglas Gregor} 320853a02c3b04d96a3c432b883e403175c954cd81Argyrios Kyrtzidis 330853a02c3b04d96a3c432b883e403175c954cd81Argyrios Kyrtzidisnamespace clang { 34521bf9c529e653ab28896d027352d3e16e2672d5Daniel Dunbarclass ASTContext; 35521bf9c529e653ab28896d027352d3e16e2672d5Daniel Dunbarclass CompilerInvocation; 36521bf9c529e653ab28896d027352d3e16e2672d5Daniel Dunbarclass Decl; 37521bf9c529e653ab28896d027352d3e16e2672d5Daniel Dunbarclass Diagnostic; 38521bf9c529e653ab28896d027352d3e16e2672d5Daniel Dunbarclass FileEntry; 39521bf9c529e653ab28896d027352d3e16e2672d5Daniel Dunbarclass FileManager; 40521bf9c529e653ab28896d027352d3e16e2672d5Daniel Dunbarclass HeaderSearch; 41521bf9c529e653ab28896d027352d3e16e2672d5Daniel Dunbarclass Preprocessor; 42521bf9c529e653ab28896d027352d3e16e2672d5Daniel Dunbarclass SourceManager; 43521bf9c529e653ab28896d027352d3e16e2672d5Daniel Dunbarclass TargetInfo; 440853a02c3b04d96a3c432b883e403175c954cd81Argyrios Kyrtzidis 45f96b524306ccfa623235d375deee79637bd38f29Steve Naroffusing namespace idx; 46f96b524306ccfa623235d375deee79637bd38f29Steve Naroff 470853a02c3b04d96a3c432b883e403175c954cd81Argyrios Kyrtzidis/// \brief Utility class for loading a ASTContext from a PCH file. 480853a02c3b04d96a3c432b883e403175c954cd81Argyrios Kyrtzidis/// 490853a02c3b04d96a3c432b883e403175c954cd81Argyrios Kyrtzidisclass ASTUnit { 5036c4464ba6cfc2a63dc67c493ef2f5ab2aea09ccSteve Naroff FileManager FileMgr; 5136c4464ba6cfc2a63dc67c493ef2f5ab2aea09ccSteve Naroff 5231b87d8006d4863dd9b17e515ac720941efc38e3Daniel Dunbar SourceManager SourceMgr; 530853a02c3b04d96a3c432b883e403175c954cd81Argyrios Kyrtzidis llvm::OwningPtr<HeaderSearch> HeaderInfo; 540853a02c3b04d96a3c432b883e403175c954cd81Argyrios Kyrtzidis llvm::OwningPtr<TargetInfo> Target; 550853a02c3b04d96a3c432b883e403175c954cd81Argyrios Kyrtzidis llvm::OwningPtr<Preprocessor> PP; 560853a02c3b04d96a3c432b883e403175c954cd81Argyrios Kyrtzidis llvm::OwningPtr<ASTContext> Ctx; 574ae8f298b1ea51b4c2234f9148e2e4349c9bdd23Douglas Gregor llvm::OwningPtr<PreprocessingRecord> Preprocessing; 584ae8f298b1ea51b4c2234f9148e2e4349c9bdd23Douglas Gregor 59807b06157a1a5c050520fc194d32f16d22d423a8Daniel Dunbar /// Optional owned invocation, just used to make the invocation used in 60807b06157a1a5c050520fc194d32f16d22d423a8Daniel Dunbar /// LoadFromCommandLine available. 61807b06157a1a5c050520fc194d32f16d22d423a8Daniel Dunbar llvm::OwningPtr<CompilerInvocation> Invocation; 62807b06157a1a5c050520fc194d32f16d22d423a8Daniel Dunbar 637d1d49d2971b20a97b3c2a301470b9eaaa130137Douglas Gregor // OnlyLocalDecls - when true, walking this AST should only visit declarations 647d1d49d2971b20a97b3c2a301470b9eaaa130137Douglas Gregor // that come from the AST itself, not from included precompiled headers. 657d1d49d2971b20a97b3c2a301470b9eaaa130137Douglas Gregor // FIXME: This is temporary; eventually, CIndex will always do this. 667d1d49d2971b20a97b3c2a301470b9eaaa130137Douglas Gregor bool OnlyLocalDecls; 67c7822dbf3c01a2a5f837cff82ba7889ea755dacaDaniel Dunbar 68f772d1e2a5688572d07f42896a50ac57a4a41fe8Daniel Dunbar /// Track whether the main file was loaded from an AST or not. 69c7822dbf3c01a2a5f837cff82ba7889ea755dacaDaniel Dunbar bool MainFileIsAST; 70c7822dbf3c01a2a5f837cff82ba7889ea755dacaDaniel Dunbar 71f772d1e2a5688572d07f42896a50ac57a4a41fe8Daniel Dunbar /// Track the top-level decls which appeared in an ASTUnit which was loaded 72f772d1e2a5688572d07f42896a50ac57a4a41fe8Daniel Dunbar /// from a source file. 73f772d1e2a5688572d07f42896a50ac57a4a41fe8Daniel Dunbar // 74f772d1e2a5688572d07f42896a50ac57a4a41fe8Daniel Dunbar // FIXME: This is just an optimization hack to avoid deserializing large parts 75f772d1e2a5688572d07f42896a50ac57a4a41fe8Daniel Dunbar // of a PCH file when using the Index library on an ASTUnit loaded from 76f772d1e2a5688572d07f42896a50ac57a4a41fe8Daniel Dunbar // source. In the long term we should make the Index library use efficient and 77f772d1e2a5688572d07f42896a50ac57a4a41fe8Daniel Dunbar // more scalable search mechanisms. 78f772d1e2a5688572d07f42896a50ac57a4a41fe8Daniel Dunbar std::vector<Decl*> TopLevelDecls; 79f772d1e2a5688572d07f42896a50ac57a4a41fe8Daniel Dunbar 8068d40e2d16b9fadba386853d6bbb60089291fdc5Daniel Dunbar /// The name of the original source file used to generate this ASTUnit. 8168d40e2d16b9fadba386853d6bbb60089291fdc5Daniel Dunbar std::string OriginalSourceFile; 8268d40e2d16b9fadba386853d6bbb60089291fdc5Daniel Dunbar 83f96b524306ccfa623235d375deee79637bd38f29Steve Naroff // Critical optimization when using clang_getCursor(). 84f96b524306ccfa623235d375deee79637bd38f29Steve Naroff ASTLocation LastLoc; 85f772d1e2a5688572d07f42896a50ac57a4a41fe8Daniel Dunbar 86a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas Gregor /// \brief The set of diagnostics produced when creating this 87a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas Gregor /// translation unit. 88a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas Gregor llvm::SmallVector<StoredDiagnostic, 4> Diagnostics; 89a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas Gregor 90313e26c4e81f0e467490a530548450f4c824a6c4Douglas Gregor /// \brief Temporary files that should be removed when the ASTUnit is 91313e26c4e81f0e467490a530548450f4c824a6c4Douglas Gregor /// destroyed. 92313e26c4e81f0e467490a530548450f4c824a6c4Douglas Gregor llvm::SmallVector<llvm::sys::Path, 4> TemporaryFiles; 93bdf6062bc10aa3b73b16402b440b8073310acd06Douglas Gregor 94bdf6062bc10aa3b73b16402b440b8073310acd06Douglas Gregor /// \brief Simple hack to allow us to assert that ASTUnit is not being 95bdf6062bc10aa3b73b16402b440b8073310acd06Douglas Gregor /// used concurrently, which is not supported. 96bdf6062bc10aa3b73b16402b440b8073310acd06Douglas Gregor /// 97bdf6062bc10aa3b73b16402b440b8073310acd06Douglas Gregor /// Clients should create instances of the ConcurrencyCheck class whenever 98bdf6062bc10aa3b73b16402b440b8073310acd06Douglas Gregor /// using the ASTUnit in a way that isn't intended to be concurrent, which is 99bdf6062bc10aa3b73b16402b440b8073310acd06Douglas Gregor /// just about any usage. 100bdf6062bc10aa3b73b16402b440b8073310acd06Douglas Gregor unsigned int ConcurrencyCheckValue; 101bdf6062bc10aa3b73b16402b440b8073310acd06Douglas Gregor static const unsigned int CheckLocked = 28573289; 102bdf6062bc10aa3b73b16402b440b8073310acd06Douglas Gregor static const unsigned int CheckUnlocked = 9803453; 103313e26c4e81f0e467490a530548450f4c824a6c4Douglas Gregor 10431b87d8006d4863dd9b17e515ac720941efc38e3Daniel Dunbar ASTUnit(const ASTUnit&); // DO NOT IMPLEMENT 10531b87d8006d4863dd9b17e515ac720941efc38e3Daniel Dunbar ASTUnit &operator=(const ASTUnit &); // DO NOT IMPLEMENT 106bdf6062bc10aa3b73b16402b440b8073310acd06Douglas Gregor 1070853a02c3b04d96a3c432b883e403175c954cd81Argyrios Kyrtzidispublic: 108bdf6062bc10aa3b73b16402b440b8073310acd06Douglas Gregor class ConcurrencyCheck { 109bdf6062bc10aa3b73b16402b440b8073310acd06Douglas Gregor volatile ASTUnit &Self; 110bdf6062bc10aa3b73b16402b440b8073310acd06Douglas Gregor 111bdf6062bc10aa3b73b16402b440b8073310acd06Douglas Gregor public: 112bdf6062bc10aa3b73b16402b440b8073310acd06Douglas Gregor explicit ConcurrencyCheck(ASTUnit &Self) 113bdf6062bc10aa3b73b16402b440b8073310acd06Douglas Gregor : Self(Self) 114bdf6062bc10aa3b73b16402b440b8073310acd06Douglas Gregor { 115bdf6062bc10aa3b73b16402b440b8073310acd06Douglas Gregor assert(Self.ConcurrencyCheckValue == CheckUnlocked && 116bdf6062bc10aa3b73b16402b440b8073310acd06Douglas Gregor "Concurrent access to ASTUnit!"); 117bdf6062bc10aa3b73b16402b440b8073310acd06Douglas Gregor Self.ConcurrencyCheckValue = CheckLocked; 118bdf6062bc10aa3b73b16402b440b8073310acd06Douglas Gregor } 119bdf6062bc10aa3b73b16402b440b8073310acd06Douglas Gregor 120bdf6062bc10aa3b73b16402b440b8073310acd06Douglas Gregor ~ConcurrencyCheck() { 121bdf6062bc10aa3b73b16402b440b8073310acd06Douglas Gregor Self.ConcurrencyCheckValue = CheckUnlocked; 122bdf6062bc10aa3b73b16402b440b8073310acd06Douglas Gregor } 123bdf6062bc10aa3b73b16402b440b8073310acd06Douglas Gregor }; 124bdf6062bc10aa3b73b16402b440b8073310acd06Douglas Gregor friend class ConcurrencyCheck; 125bdf6062bc10aa3b73b16402b440b8073310acd06Douglas Gregor 126f715ca12bfc9fddfde75f98a197424434428b821Douglas Gregor ASTUnit(Diagnostic &Diag, bool MainFileIsAST); 1270853a02c3b04d96a3c432b883e403175c954cd81Argyrios Kyrtzidis ~ASTUnit(); 1280853a02c3b04d96a3c432b883e403175c954cd81Argyrios Kyrtzidis 129c7822dbf3c01a2a5f837cff82ba7889ea755dacaDaniel Dunbar bool isMainFileAST() const { return MainFileIsAST; } 130c7822dbf3c01a2a5f837cff82ba7889ea755dacaDaniel Dunbar 13131b87d8006d4863dd9b17e515ac720941efc38e3Daniel Dunbar const SourceManager &getSourceManager() const { return SourceMgr; } 13231b87d8006d4863dd9b17e515ac720941efc38e3Daniel Dunbar SourceManager &getSourceManager() { return SourceMgr; } 1330853a02c3b04d96a3c432b883e403175c954cd81Argyrios Kyrtzidis 1340853a02c3b04d96a3c432b883e403175c954cd81Argyrios Kyrtzidis const Preprocessor &getPreprocessor() const { return *PP.get(); } 1350853a02c3b04d96a3c432b883e403175c954cd81Argyrios Kyrtzidis Preprocessor &getPreprocessor() { return *PP.get(); } 1361eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1370853a02c3b04d96a3c432b883e403175c954cd81Argyrios Kyrtzidis const ASTContext &getASTContext() const { return *Ctx.get(); } 1380853a02c3b04d96a3c432b883e403175c954cd81Argyrios Kyrtzidis ASTContext &getASTContext() { return *Ctx.get(); } 1390853a02c3b04d96a3c432b883e403175c954cd81Argyrios Kyrtzidis 1404ae8f298b1ea51b4c2234f9148e2e4349c9bdd23Douglas Gregor const PreprocessingRecord &getPreprocessingRecord() const { 1414ae8f298b1ea51b4c2234f9148e2e4349c9bdd23Douglas Gregor return *Preprocessing.get(); 1424ae8f298b1ea51b4c2234f9148e2e4349c9bdd23Douglas Gregor } 1434ae8f298b1ea51b4c2234f9148e2e4349c9bdd23Douglas Gregor PreprocessingRecord &getPreprocessingRecord() { return *Preprocessing.get(); } 1444ae8f298b1ea51b4c2234f9148e2e4349c9bdd23Douglas Gregor bool hasPreprocessingRecord() { return Preprocessing.get() != 0; } 1454ae8f298b1ea51b4c2234f9148e2e4349c9bdd23Douglas Gregor 14636c4464ba6cfc2a63dc67c493ef2f5ab2aea09ccSteve Naroff const FileManager &getFileManager() const { return FileMgr; } 14736c4464ba6cfc2a63dc67c493ef2f5ab2aea09ccSteve Naroff FileManager &getFileManager() { return FileMgr; } 148f772d1e2a5688572d07f42896a50ac57a4a41fe8Daniel Dunbar 14977accc11f04ed4ff9afd4e27d430144d4714be56Steve Naroff const std::string &getOriginalSourceFileName(); 150e19944c93961b7618f4f3f3185f698f46369ea54Steve Naroff const std::string &getPCHFileName(); 151b85bca2676b433ae555db09de4dd2823ff13b856Zhongxing Xu 152313e26c4e81f0e467490a530548450f4c824a6c4Douglas Gregor /// \brief Add a temporary file that the ASTUnit depends on. 153313e26c4e81f0e467490a530548450f4c824a6c4Douglas Gregor /// 154313e26c4e81f0e467490a530548450f4c824a6c4Douglas Gregor /// This file will be erased when the ASTUnit is destroyed. 155313e26c4e81f0e467490a530548450f4c824a6c4Douglas Gregor void addTemporaryFile(const llvm::sys::Path &TempFile) { 156313e26c4e81f0e467490a530548450f4c824a6c4Douglas Gregor TemporaryFiles.push_back(TempFile); 157313e26c4e81f0e467490a530548450f4c824a6c4Douglas Gregor } 158313e26c4e81f0e467490a530548450f4c824a6c4Douglas Gregor 1597d1d49d2971b20a97b3c2a301470b9eaaa130137Douglas Gregor bool getOnlyLocalDecls() const { return OnlyLocalDecls; } 160f772d1e2a5688572d07f42896a50ac57a4a41fe8Daniel Dunbar 161f96b524306ccfa623235d375deee79637bd38f29Steve Naroff void setLastASTLocation(ASTLocation ALoc) { LastLoc = ALoc; } 162f96b524306ccfa623235d375deee79637bd38f29Steve Naroff ASTLocation getLastASTLocation() const { return LastLoc; } 163f772d1e2a5688572d07f42896a50ac57a4a41fe8Daniel Dunbar 164f772d1e2a5688572d07f42896a50ac57a4a41fe8Daniel Dunbar std::vector<Decl*> &getTopLevelDecls() { 165f772d1e2a5688572d07f42896a50ac57a4a41fe8Daniel Dunbar assert(!isMainFileAST() && "Invalid call for AST based ASTUnit!"); 166f772d1e2a5688572d07f42896a50ac57a4a41fe8Daniel Dunbar return TopLevelDecls; 167f772d1e2a5688572d07f42896a50ac57a4a41fe8Daniel Dunbar } 168f772d1e2a5688572d07f42896a50ac57a4a41fe8Daniel Dunbar const std::vector<Decl*> &getTopLevelDecls() const { 169f772d1e2a5688572d07f42896a50ac57a4a41fe8Daniel Dunbar assert(!isMainFileAST() && "Invalid call for AST based ASTUnit!"); 170f772d1e2a5688572d07f42896a50ac57a4a41fe8Daniel Dunbar return TopLevelDecls; 171f772d1e2a5688572d07f42896a50ac57a4a41fe8Daniel Dunbar } 172f772d1e2a5688572d07f42896a50ac57a4a41fe8Daniel Dunbar 173a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas Gregor // Retrieve the diagnostics associated with this AST 174a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas Gregor typedef const StoredDiagnostic * diag_iterator; 175a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas Gregor diag_iterator diag_begin() const { return Diagnostics.begin(); } 176a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas Gregor diag_iterator diag_end() const { return Diagnostics.end(); } 177a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas Gregor unsigned diag_size() const { return Diagnostics.size(); } 178a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas Gregor llvm::SmallVector<StoredDiagnostic, 4> &getDiagnostics() { 179a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas Gregor return Diagnostics; 180a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas Gregor } 181a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas Gregor 1824db64a461cb3442934afe43c83ed3f17f7c11c1dDouglas Gregor /// \brief A mapping from a file name to the memory buffer that stores the 1834db64a461cb3442934afe43c83ed3f17f7c11c1dDouglas Gregor /// remapped contents of that file. 1844db64a461cb3442934afe43c83ed3f17f7c11c1dDouglas Gregor typedef std::pair<std::string, const llvm::MemoryBuffer *> RemappedFile; 1854db64a461cb3442934afe43c83ed3f17f7c11c1dDouglas Gregor 1860853a02c3b04d96a3c432b883e403175c954cd81Argyrios Kyrtzidis /// \brief Create a ASTUnit from a PCH file. 1870853a02c3b04d96a3c432b883e403175c954cd81Argyrios Kyrtzidis /// 18831b87d8006d4863dd9b17e515ac720941efc38e3Daniel Dunbar /// \param Filename - The PCH file to load. 1890853a02c3b04d96a3c432b883e403175c954cd81Argyrios Kyrtzidis /// 1905262fda30b876c8aae95f2eb92e349418d6b14bbDaniel Dunbar /// \param Diags - The diagnostics engine to use for reporting errors; its 1915262fda30b876c8aae95f2eb92e349418d6b14bbDaniel Dunbar /// lifetime is expected to extend past that of the returned ASTUnit. 19231b87d8006d4863dd9b17e515ac720941efc38e3Daniel Dunbar /// 19331b87d8006d4863dd9b17e515ac720941efc38e3Daniel Dunbar /// \returns - The initialized ASTUnit or null if the PCH failed to load. 1940853a02c3b04d96a3c432b883e403175c954cd81Argyrios Kyrtzidis static ASTUnit *LoadFromPCHFile(const std::string &Filename, 1955262fda30b876c8aae95f2eb92e349418d6b14bbDaniel Dunbar Diagnostic &Diags, 1965cf48766d626ff6b223acc9d4b7e415ca8480836Ted Kremenek bool OnlyLocalDecls = false, 1974db64a461cb3442934afe43c83ed3f17f7c11c1dDouglas Gregor RemappedFile *RemappedFiles = 0, 198a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas Gregor unsigned NumRemappedFiles = 0, 199a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas Gregor bool CaptureDiagnostics = false); 200521bf9c529e653ab28896d027352d3e16e2672d5Daniel Dunbar 201521bf9c529e653ab28896d027352d3e16e2672d5Daniel Dunbar /// LoadFromCompilerInvocation - Create an ASTUnit from a source file, via a 202521bf9c529e653ab28896d027352d3e16e2672d5Daniel Dunbar /// CompilerInvocation object. 203521bf9c529e653ab28896d027352d3e16e2672d5Daniel Dunbar /// 204521bf9c529e653ab28896d027352d3e16e2672d5Daniel Dunbar /// \param CI - The compiler invocation to use; it must have exactly one input 205f7acc37450d59ef751df73acb91de73850cc6517Daniel Dunbar /// source file. The ASTUnit takes ownership of the CompilerInvocation object. 206521bf9c529e653ab28896d027352d3e16e2672d5Daniel Dunbar /// 2075262fda30b876c8aae95f2eb92e349418d6b14bbDaniel Dunbar /// \param Diags - The diagnostics engine to use for reporting errors; its 2085262fda30b876c8aae95f2eb92e349418d6b14bbDaniel Dunbar /// lifetime is expected to extend past that of the returned ASTUnit. 209521bf9c529e653ab28896d027352d3e16e2672d5Daniel Dunbar // 210521bf9c529e653ab28896d027352d3e16e2672d5Daniel Dunbar // FIXME: Move OnlyLocalDecls, UseBumpAllocator to setters on the ASTUnit, we 211521bf9c529e653ab28896d027352d3e16e2672d5Daniel Dunbar // shouldn't need to specify them at construction time. 212f7acc37450d59ef751df73acb91de73850cc6517Daniel Dunbar static ASTUnit *LoadFromCompilerInvocation(CompilerInvocation *CI, 213521bf9c529e653ab28896d027352d3e16e2672d5Daniel Dunbar Diagnostic &Diags, 214a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas Gregor bool OnlyLocalDecls = false, 2154ae8f298b1ea51b4c2234f9148e2e4349c9bdd23Douglas Gregor bool CaptureDiagnostics = false, 2164ae8f298b1ea51b4c2234f9148e2e4349c9bdd23Douglas Gregor bool WantPreprocessingRecord = false); 217521bf9c529e653ab28896d027352d3e16e2672d5Daniel Dunbar 2187b55668db7618334cc40011d3c1e128524d89462Daniel Dunbar /// LoadFromCommandLine - Create an ASTUnit from a vector of command line 2197b55668db7618334cc40011d3c1e128524d89462Daniel Dunbar /// arguments, which must specify exactly one source file. 2207b55668db7618334cc40011d3c1e128524d89462Daniel Dunbar /// 2217b55668db7618334cc40011d3c1e128524d89462Daniel Dunbar /// \param ArgBegin - The beginning of the argument vector. 2227b55668db7618334cc40011d3c1e128524d89462Daniel Dunbar /// 2237b55668db7618334cc40011d3c1e128524d89462Daniel Dunbar /// \param ArgEnd - The end of the argument vector. 2247b55668db7618334cc40011d3c1e128524d89462Daniel Dunbar /// 2255262fda30b876c8aae95f2eb92e349418d6b14bbDaniel Dunbar /// \param Diags - The diagnostics engine to use for reporting errors; its 2265262fda30b876c8aae95f2eb92e349418d6b14bbDaniel Dunbar /// lifetime is expected to extend past that of the returned ASTUnit. 2277b55668db7618334cc40011d3c1e128524d89462Daniel Dunbar /// 228869824e87940f97b87064db2df2861e82e08a8c6Daniel Dunbar /// \param ResourceFilesPath - The path to the compiler resource files. 2297b55668db7618334cc40011d3c1e128524d89462Daniel Dunbar // 2307b55668db7618334cc40011d3c1e128524d89462Daniel Dunbar // FIXME: Move OnlyLocalDecls, UseBumpAllocator to setters on the ASTUnit, we 2317b55668db7618334cc40011d3c1e128524d89462Daniel Dunbar // shouldn't need to specify them at construction time. 2327b55668db7618334cc40011d3c1e128524d89462Daniel Dunbar static ASTUnit *LoadFromCommandLine(const char **ArgBegin, 2337b55668db7618334cc40011d3c1e128524d89462Daniel Dunbar const char **ArgEnd, 2347b55668db7618334cc40011d3c1e128524d89462Daniel Dunbar Diagnostic &Diags, 235869824e87940f97b87064db2df2861e82e08a8c6Daniel Dunbar llvm::StringRef ResourceFilesPath, 2367b55668db7618334cc40011d3c1e128524d89462Daniel Dunbar bool OnlyLocalDecls = false, 2374db64a461cb3442934afe43c83ed3f17f7c11c1dDouglas Gregor RemappedFile *RemappedFiles = 0, 238a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas Gregor unsigned NumRemappedFiles = 0, 2394ae8f298b1ea51b4c2234f9148e2e4349c9bdd23Douglas Gregor bool CaptureDiagnostics = false, 2404ae8f298b1ea51b4c2234f9148e2e4349c9bdd23Douglas Gregor bool WantPreprocessingRecord = false); 2410853a02c3b04d96a3c432b883e403175c954cd81Argyrios Kyrtzidis}; 2420853a02c3b04d96a3c432b883e403175c954cd81Argyrios Kyrtzidis 2430853a02c3b04d96a3c432b883e403175c954cd81Argyrios Kyrtzidis} // namespace clang 2440853a02c3b04d96a3c432b883e403175c954cd81Argyrios Kyrtzidis 2450853a02c3b04d96a3c432b883e403175c954cd81Argyrios Kyrtzidis#endif 246