ASTUnit.h revision df95a13ec73d2cdaea79555cb412d767f4963120
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 17eb8837b88c18631c69ac75f64ab1853762063180Douglas Gregor#include "clang/Index/ASTLocation.h" 18eb8837b88c18631c69ac75f64ab1853762063180Douglas Gregor#include "clang/Frontend/PCHBitCodes.h" 194ae8f298b1ea51b4c2234f9148e2e4349c9bdd23Douglas Gregor#include "clang/Lex/PreprocessingRecord.h" 2031b87d8006d4863dd9b17e515ac720941efc38e3Daniel Dunbar#include "clang/Basic/SourceManager.h" 21eb8837b88c18631c69ac75f64ab1853762063180Douglas Gregor#include "clang/Basic/FileManager.h" 2228019772db70d4547be05a042eb950bc910f134fDouglas Gregor#include "llvm/ADT/IntrusiveRefCntPtr.h" 230853a02c3b04d96a3c432b883e403175c954cd81Argyrios Kyrtzidis#include "llvm/ADT/OwningPtr.h" 24a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas Gregor#include "llvm/ADT/SmallVector.h" 25cc5888d833caf90ebda37f24da40d2cd06b4d820Douglas Gregor#include "llvm/ADT/StringMap.h" 26313e26c4e81f0e467490a530548450f4c824a6c4Douglas Gregor#include "llvm/System/Path.h" 27385103b79c5338a2be5da0ca70652400bc267371Douglas Gregor#include "llvm/Support/Timer.h" 28788f5a1242c04762f91eaa7565c07b9865846d88Douglas Gregor#include <map> 290853a02c3b04d96a3c432b883e403175c954cd81Argyrios Kyrtzidis#include <string> 30f772d1e2a5688572d07f42896a50ac57a4a41fe8Daniel Dunbar#include <vector> 31f772d1e2a5688572d07f42896a50ac57a4a41fe8Daniel Dunbar#include <cassert> 324db64a461cb3442934afe43c83ed3f17f7c11c1dDouglas Gregor#include <utility> 33cc5888d833caf90ebda37f24da40d2cd06b4d820Douglas Gregor#include <sys/types.h> 344db64a461cb3442934afe43c83ed3f17f7c11c1dDouglas Gregor 354db64a461cb3442934afe43c83ed3f17f7c11c1dDouglas Gregornamespace llvm { 364db64a461cb3442934afe43c83ed3f17f7c11c1dDouglas Gregor class MemoryBuffer; 374db64a461cb3442934afe43c83ed3f17f7c11c1dDouglas Gregor} 380853a02c3b04d96a3c432b883e403175c954cd81Argyrios Kyrtzidis 390853a02c3b04d96a3c432b883e403175c954cd81Argyrios Kyrtzidisnamespace clang { 40521bf9c529e653ab28896d027352d3e16e2672d5Daniel Dunbarclass ASTContext; 411abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregorclass CodeCompleteConsumer; 42521bf9c529e653ab28896d027352d3e16e2672d5Daniel Dunbarclass CompilerInvocation; 43521bf9c529e653ab28896d027352d3e16e2672d5Daniel Dunbarclass Decl; 44521bf9c529e653ab28896d027352d3e16e2672d5Daniel Dunbarclass Diagnostic; 45521bf9c529e653ab28896d027352d3e16e2672d5Daniel Dunbarclass FileEntry; 46521bf9c529e653ab28896d027352d3e16e2672d5Daniel Dunbarclass FileManager; 47521bf9c529e653ab28896d027352d3e16e2672d5Daniel Dunbarclass HeaderSearch; 48521bf9c529e653ab28896d027352d3e16e2672d5Daniel Dunbarclass Preprocessor; 49521bf9c529e653ab28896d027352d3e16e2672d5Daniel Dunbarclass SourceManager; 50521bf9c529e653ab28896d027352d3e16e2672d5Daniel Dunbarclass TargetInfo; 510853a02c3b04d96a3c432b883e403175c954cd81Argyrios Kyrtzidis 52f96b524306ccfa623235d375deee79637bd38f29Steve Naroffusing namespace idx; 5344c181aec37789f25f6c15543c164416f72e562aDouglas Gregor 540853a02c3b04d96a3c432b883e403175c954cd81Argyrios Kyrtzidis/// \brief Utility class for loading a ASTContext from a PCH file. 550853a02c3b04d96a3c432b883e403175c954cd81Argyrios Kyrtzidis/// 560853a02c3b04d96a3c432b883e403175c954cd81Argyrios Kyrtzidisclass ASTUnit { 57788f5a1242c04762f91eaa7565c07b9865846d88Douglas Gregorpublic: 58788f5a1242c04762f91eaa7565c07b9865846d88Douglas Gregor typedef std::map<FileID, std::vector<PreprocessedEntity *> > 59788f5a1242c04762f91eaa7565c07b9865846d88Douglas Gregor PreprocessedEntitiesByFileMap; 60788f5a1242c04762f91eaa7565c07b9865846d88Douglas Gregorprivate: 6128019772db70d4547be05a042eb950bc910f134fDouglas Gregor llvm::IntrusiveRefCntPtr<Diagnostic> Diagnostics; 62405634b215f19eec7183bd8005e34aa5a02f64a1Douglas Gregor llvm::OwningPtr<FileManager> FileMgr; 63405634b215f19eec7183bd8005e34aa5a02f64a1Douglas Gregor llvm::OwningPtr<SourceManager> SourceMgr; 640853a02c3b04d96a3c432b883e403175c954cd81Argyrios Kyrtzidis llvm::OwningPtr<HeaderSearch> HeaderInfo; 650853a02c3b04d96a3c432b883e403175c954cd81Argyrios Kyrtzidis llvm::OwningPtr<TargetInfo> Target; 660853a02c3b04d96a3c432b883e403175c954cd81Argyrios Kyrtzidis llvm::OwningPtr<Preprocessor> PP; 670853a02c3b04d96a3c432b883e403175c954cd81Argyrios Kyrtzidis llvm::OwningPtr<ASTContext> Ctx; 684ae8f298b1ea51b4c2234f9148e2e4349c9bdd23Douglas Gregor 69807b06157a1a5c050520fc194d32f16d22d423a8Daniel Dunbar /// Optional owned invocation, just used to make the invocation used in 70807b06157a1a5c050520fc194d32f16d22d423a8Daniel Dunbar /// LoadFromCommandLine available. 71807b06157a1a5c050520fc194d32f16d22d423a8Daniel Dunbar llvm::OwningPtr<CompilerInvocation> Invocation; 72807b06157a1a5c050520fc194d32f16d22d423a8Daniel Dunbar 737d1d49d2971b20a97b3c2a301470b9eaaa130137Douglas Gregor // OnlyLocalDecls - when true, walking this AST should only visit declarations 747d1d49d2971b20a97b3c2a301470b9eaaa130137Douglas Gregor // that come from the AST itself, not from included precompiled headers. 757d1d49d2971b20a97b3c2a301470b9eaaa130137Douglas Gregor // FIXME: This is temporary; eventually, CIndex will always do this. 767d1d49d2971b20a97b3c2a301470b9eaaa130137Douglas Gregor bool OnlyLocalDecls; 77c7822dbf3c01a2a5f837cff82ba7889ea755dacaDaniel Dunbar 78abc563f554951259bbe0315055cad92ee14d87e4Douglas Gregor /// \brief Whether to capture any diagnostics produced. 79abc563f554951259bbe0315055cad92ee14d87e4Douglas Gregor bool CaptureDiagnostics; 80abc563f554951259bbe0315055cad92ee14d87e4Douglas Gregor 81df95a13ec73d2cdaea79555cb412d767f4963120Douglas Gregor /// \brief Track whether the main file was loaded from an AST or not. 82c7822dbf3c01a2a5f837cff82ba7889ea755dacaDaniel Dunbar bool MainFileIsAST; 83c7822dbf3c01a2a5f837cff82ba7889ea755dacaDaniel Dunbar 84df95a13ec73d2cdaea79555cb412d767f4963120Douglas Gregor /// \brief Whether this AST represents a complete translation unit. 85df95a13ec73d2cdaea79555cb412d767f4963120Douglas Gregor bool CompleteTranslationUnit; 86df95a13ec73d2cdaea79555cb412d767f4963120Douglas Gregor 87f772d1e2a5688572d07f42896a50ac57a4a41fe8Daniel Dunbar /// Track the top-level decls which appeared in an ASTUnit which was loaded 88f772d1e2a5688572d07f42896a50ac57a4a41fe8Daniel Dunbar /// from a source file. 89f772d1e2a5688572d07f42896a50ac57a4a41fe8Daniel Dunbar // 90f772d1e2a5688572d07f42896a50ac57a4a41fe8Daniel Dunbar // FIXME: This is just an optimization hack to avoid deserializing large parts 91f772d1e2a5688572d07f42896a50ac57a4a41fe8Daniel Dunbar // of a PCH file when using the Index library on an ASTUnit loaded from 92f772d1e2a5688572d07f42896a50ac57a4a41fe8Daniel Dunbar // source. In the long term we should make the Index library use efficient and 93f772d1e2a5688572d07f42896a50ac57a4a41fe8Daniel Dunbar // more scalable search mechanisms. 94f772d1e2a5688572d07f42896a50ac57a4a41fe8Daniel Dunbar std::vector<Decl*> TopLevelDecls; 95f772d1e2a5688572d07f42896a50ac57a4a41fe8Daniel Dunbar 9668d40e2d16b9fadba386853d6bbb60089291fdc5Daniel Dunbar /// The name of the original source file used to generate this ASTUnit. 9768d40e2d16b9fadba386853d6bbb60089291fdc5Daniel Dunbar std::string OriginalSourceFile; 9868d40e2d16b9fadba386853d6bbb60089291fdc5Daniel Dunbar 99f96b524306ccfa623235d375deee79637bd38f29Steve Naroff // Critical optimization when using clang_getCursor(). 100f96b524306ccfa623235d375deee79637bd38f29Steve Naroff ASTLocation LastLoc; 101f772d1e2a5688572d07f42896a50ac57a4a41fe8Daniel Dunbar 102a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas Gregor /// \brief The set of diagnostics produced when creating this 103a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas Gregor /// translation unit. 104405634b215f19eec7183bd8005e34aa5a02f64a1Douglas Gregor llvm::SmallVector<StoredDiagnostic, 4> StoredDiagnostics; 105a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas Gregor 106313e26c4e81f0e467490a530548450f4c824a6c4Douglas Gregor /// \brief Temporary files that should be removed when the ASTUnit is 107313e26c4e81f0e467490a530548450f4c824a6c4Douglas Gregor /// destroyed. 108313e26c4e81f0e467490a530548450f4c824a6c4Douglas Gregor llvm::SmallVector<llvm::sys::Path, 4> TemporaryFiles; 109bdf6062bc10aa3b73b16402b440b8073310acd06Douglas Gregor 110788f5a1242c04762f91eaa7565c07b9865846d88Douglas Gregor /// \brief A mapping from file IDs to the set of preprocessed entities 111788f5a1242c04762f91eaa7565c07b9865846d88Douglas Gregor /// stored in that file. 112788f5a1242c04762f91eaa7565c07b9865846d88Douglas Gregor /// 113788f5a1242c04762f91eaa7565c07b9865846d88Douglas Gregor /// FIXME: This is just an optimization hack to avoid searching through 114788f5a1242c04762f91eaa7565c07b9865846d88Douglas Gregor /// many preprocessed entities during cursor traversal in the CIndex library. 115788f5a1242c04762f91eaa7565c07b9865846d88Douglas Gregor /// Ideally, we would just be able to perform a binary search within the 116788f5a1242c04762f91eaa7565c07b9865846d88Douglas Gregor /// list of preprocessed entities. 117788f5a1242c04762f91eaa7565c07b9865846d88Douglas Gregor PreprocessedEntitiesByFileMap PreprocessedEntitiesByFile; 118788f5a1242c04762f91eaa7565c07b9865846d88Douglas Gregor 119bdf6062bc10aa3b73b16402b440b8073310acd06Douglas Gregor /// \brief Simple hack to allow us to assert that ASTUnit is not being 120bdf6062bc10aa3b73b16402b440b8073310acd06Douglas Gregor /// used concurrently, which is not supported. 121bdf6062bc10aa3b73b16402b440b8073310acd06Douglas Gregor /// 122bdf6062bc10aa3b73b16402b440b8073310acd06Douglas Gregor /// Clients should create instances of the ConcurrencyCheck class whenever 123bdf6062bc10aa3b73b16402b440b8073310acd06Douglas Gregor /// using the ASTUnit in a way that isn't intended to be concurrent, which is 124bdf6062bc10aa3b73b16402b440b8073310acd06Douglas Gregor /// just about any usage. 125bdf6062bc10aa3b73b16402b440b8073310acd06Douglas Gregor unsigned int ConcurrencyCheckValue; 126bdf6062bc10aa3b73b16402b440b8073310acd06Douglas Gregor static const unsigned int CheckLocked = 28573289; 127bdf6062bc10aa3b73b16402b440b8073310acd06Douglas Gregor static const unsigned int CheckUnlocked = 9803453; 128175c4a9aa61f4449f27b729737e4438684ac6d92Douglas Gregor 129eababfbddb74d186f78783a9731a78ad371c9800Douglas Gregor /// \brief Counter that determines when we want to try building a 130eababfbddb74d186f78783a9731a78ad371c9800Douglas Gregor /// precompiled preamble. 131eababfbddb74d186f78783a9731a78ad371c9800Douglas Gregor /// 132eababfbddb74d186f78783a9731a78ad371c9800Douglas Gregor /// If zero, we will never build a precompiled preamble. Otherwise, 133eababfbddb74d186f78783a9731a78ad371c9800Douglas Gregor /// it's treated as a counter that decrements each time we reparse 134eababfbddb74d186f78783a9731a78ad371c9800Douglas Gregor /// without the benefit of a precompiled preamble. When it hits 1, 135eababfbddb74d186f78783a9731a78ad371c9800Douglas Gregor /// we'll attempt to rebuild the precompiled header. This way, if 136eababfbddb74d186f78783a9731a78ad371c9800Douglas Gregor /// building the precompiled preamble fails, we won't try again for 137eababfbddb74d186f78783a9731a78ad371c9800Douglas Gregor /// some number of calls. 138eababfbddb74d186f78783a9731a78ad371c9800Douglas Gregor unsigned PreambleRebuildCounter; 139eababfbddb74d186f78783a9731a78ad371c9800Douglas Gregor 140175c4a9aa61f4449f27b729737e4438684ac6d92Douglas Gregor /// \brief The file in which the precompiled preamble is stored. 141385103b79c5338a2be5da0ca70652400bc267371Douglas Gregor std::string PreambleFile; 142175c4a9aa61f4449f27b729737e4438684ac6d92Douglas Gregor 143175c4a9aa61f4449f27b729737e4438684ac6d92Douglas Gregor /// \brief The contents of the preamble that has been precompiled to 144175c4a9aa61f4449f27b729737e4438684ac6d92Douglas Gregor /// \c PreambleFile. 145175c4a9aa61f4449f27b729737e4438684ac6d92Douglas Gregor std::vector<char> Preamble; 146175c4a9aa61f4449f27b729737e4438684ac6d92Douglas Gregor 147f4f6c9db68465b886ec2e596feaa6ecc782395a4Douglas Gregor /// \brief Whether the preamble ends at the start of a new line. 148f4f6c9db68465b886ec2e596feaa6ecc782395a4Douglas Gregor /// 149f4f6c9db68465b886ec2e596feaa6ecc782395a4Douglas Gregor /// Used to inform the lexer as to whether it's starting at the beginning of 150f4f6c9db68465b886ec2e596feaa6ecc782395a4Douglas Gregor /// a line after skipping the preamble. 151f4f6c9db68465b886ec2e596feaa6ecc782395a4Douglas Gregor bool PreambleEndsAtStartOfLine; 152f4f6c9db68465b886ec2e596feaa6ecc782395a4Douglas Gregor 153175c4a9aa61f4449f27b729737e4438684ac6d92Douglas Gregor /// \brief The size of the source buffer that we've reserved for the main 154175c4a9aa61f4449f27b729737e4438684ac6d92Douglas Gregor /// file within the precompiled preamble. 155175c4a9aa61f4449f27b729737e4438684ac6d92Douglas Gregor unsigned PreambleReservedSize; 156cc5888d833caf90ebda37f24da40d2cd06b4d820Douglas Gregor 157cc5888d833caf90ebda37f24da40d2cd06b4d820Douglas Gregor /// \brief Keeps track of the files that were used when computing the 158cc5888d833caf90ebda37f24da40d2cd06b4d820Douglas Gregor /// preamble, with both their buffer size and their modification time. 159cc5888d833caf90ebda37f24da40d2cd06b4d820Douglas Gregor /// 160cc5888d833caf90ebda37f24da40d2cd06b4d820Douglas Gregor /// If any of the files have changed from one compile to the next, 161cc5888d833caf90ebda37f24da40d2cd06b4d820Douglas Gregor /// the preamble must be thrown away. 162cc5888d833caf90ebda37f24da40d2cd06b4d820Douglas Gregor llvm::StringMap<std::pair<off_t, time_t> > FilesInPreamble; 163cc5888d833caf90ebda37f24da40d2cd06b4d820Douglas Gregor 16428233428da1ebec20c893d6297ae3191318940ddDouglas Gregor /// \brief When non-NULL, this is the buffer used to store the contents of 16528233428da1ebec20c893d6297ae3191318940ddDouglas Gregor /// the main file when it has been padded for use with the precompiled 16628233428da1ebec20c893d6297ae3191318940ddDouglas Gregor /// preamble. 16728233428da1ebec20c893d6297ae3191318940ddDouglas Gregor llvm::MemoryBuffer *SavedMainFileBuffer; 168c0659ec614c428c7d15746fcad15d50a2703751dDouglas Gregor 169c0659ec614c428c7d15746fcad15d50a2703751dDouglas Gregor /// \brief The number of warnings that occurred while parsing the preamble. 170c0659ec614c428c7d15746fcad15d50a2703751dDouglas Gregor /// 171c0659ec614c428c7d15746fcad15d50a2703751dDouglas Gregor /// This value will be used to restore the state of the \c Diagnostic object 172c0659ec614c428c7d15746fcad15d50a2703751dDouglas Gregor /// when re-using the precompiled preamble. Note that only the 173c0659ec614c428c7d15746fcad15d50a2703751dDouglas Gregor /// number of warnings matters, since we will not save the preamble 174c0659ec614c428c7d15746fcad15d50a2703751dDouglas Gregor /// when any errors are present. 175c0659ec614c428c7d15746fcad15d50a2703751dDouglas Gregor unsigned NumWarningsInPreamble; 176c0659ec614c428c7d15746fcad15d50a2703751dDouglas Gregor 177c0659ec614c428c7d15746fcad15d50a2703751dDouglas Gregor /// \brief The number of diagnostics that were stored when parsing 178c0659ec614c428c7d15746fcad15d50a2703751dDouglas Gregor /// the precompiled preamble. 179c0659ec614c428c7d15746fcad15d50a2703751dDouglas Gregor /// 180c0659ec614c428c7d15746fcad15d50a2703751dDouglas Gregor /// This value is used to determine how many of the stored 181c0659ec614c428c7d15746fcad15d50a2703751dDouglas Gregor /// diagnostics should be retained when reparsing in the presence of 182c0659ec614c428c7d15746fcad15d50a2703751dDouglas Gregor /// a precompiled preamble. 183c0659ec614c428c7d15746fcad15d50a2703751dDouglas Gregor unsigned NumStoredDiagnosticsInPreamble; 184c0659ec614c428c7d15746fcad15d50a2703751dDouglas Gregor 185385103b79c5338a2be5da0ca70652400bc267371Douglas Gregor /// \brief The group of timers associated with this translation unit. 186cc5888d833caf90ebda37f24da40d2cd06b4d820Douglas Gregor llvm::OwningPtr<llvm::TimerGroup> TimerGroup; 187eb8837b88c18631c69ac75f64ab1853762063180Douglas Gregor 188eb8837b88c18631c69ac75f64ab1853762063180Douglas Gregor /// \brief A list of the PCH ID numbers for each of the top-level 189eb8837b88c18631c69ac75f64ab1853762063180Douglas Gregor /// declarations parsed within the precompiled preamble. 190eb8837b88c18631c69ac75f64ab1853762063180Douglas Gregor std::vector<pch::DeclID> TopLevelDeclsInPreamble; 191eb8837b88c18631c69ac75f64ab1853762063180Douglas Gregor 192385103b79c5338a2be5da0ca70652400bc267371Douglas Gregor /// \brief The timers we've created from the various parses, reparses, etc. 193385103b79c5338a2be5da0ca70652400bc267371Douglas Gregor /// involved in this translation unit. 194385103b79c5338a2be5da0ca70652400bc267371Douglas Gregor std::vector<llvm::Timer *> Timers; 195385103b79c5338a2be5da0ca70652400bc267371Douglas Gregor 19631b87d8006d4863dd9b17e515ac720941efc38e3Daniel Dunbar ASTUnit(const ASTUnit&); // DO NOT IMPLEMENT 19731b87d8006d4863dd9b17e515ac720941efc38e3Daniel Dunbar ASTUnit &operator=(const ASTUnit &); // DO NOT IMPLEMENT 198bdf6062bc10aa3b73b16402b440b8073310acd06Douglas Gregor 1993687e9d3a5dbfa9963af02a49a2b139d91310813Douglas Gregor explicit ASTUnit(bool MainFileIsAST); 2008b96253907c47141af0b7b2a44a368748d006a87Douglas Gregor 201abc563f554951259bbe0315055cad92ee14d87e4Douglas Gregor void CleanTemporaryFiles(); 202754f3490c5b0f5d83361f001bc87944f23644abbDouglas Gregor bool Parse(llvm::MemoryBuffer *OverrideMainBuffer); 203175c4a9aa61f4449f27b729737e4438684ac6d92Douglas Gregor 204f4f6c9db68465b886ec2e596feaa6ecc782395a4Douglas Gregor std::pair<llvm::MemoryBuffer *, std::pair<unsigned, bool> > 205df95a13ec73d2cdaea79555cb412d767f4963120Douglas Gregor ComputePreamble(CompilerInvocation &Invocation, 206df95a13ec73d2cdaea79555cb412d767f4963120Douglas Gregor unsigned MaxLines, bool &CreatedBuffer); 207175c4a9aa61f4449f27b729737e4438684ac6d92Douglas Gregor 208df95a13ec73d2cdaea79555cb412d767f4963120Douglas Gregor llvm::MemoryBuffer *getMainBufferWithPrecompiledPreamble( 209df95a13ec73d2cdaea79555cb412d767f4963120Douglas Gregor bool AllowRebuild = true, 210df95a13ec73d2cdaea79555cb412d767f4963120Douglas Gregor unsigned MaxLines = 0); 211eb8837b88c18631c69ac75f64ab1853762063180Douglas Gregor void RealizeTopLevelDeclsFromPreamble(); 212eb8837b88c18631c69ac75f64ab1853762063180Douglas Gregor 2130853a02c3b04d96a3c432b883e403175c954cd81Argyrios Kyrtzidispublic: 214bdf6062bc10aa3b73b16402b440b8073310acd06Douglas Gregor class ConcurrencyCheck { 215bdf6062bc10aa3b73b16402b440b8073310acd06Douglas Gregor volatile ASTUnit &Self; 216bdf6062bc10aa3b73b16402b440b8073310acd06Douglas Gregor 217bdf6062bc10aa3b73b16402b440b8073310acd06Douglas Gregor public: 218bdf6062bc10aa3b73b16402b440b8073310acd06Douglas Gregor explicit ConcurrencyCheck(ASTUnit &Self) 219bdf6062bc10aa3b73b16402b440b8073310acd06Douglas Gregor : Self(Self) 220bdf6062bc10aa3b73b16402b440b8073310acd06Douglas Gregor { 221bdf6062bc10aa3b73b16402b440b8073310acd06Douglas Gregor assert(Self.ConcurrencyCheckValue == CheckUnlocked && 222bdf6062bc10aa3b73b16402b440b8073310acd06Douglas Gregor "Concurrent access to ASTUnit!"); 223bdf6062bc10aa3b73b16402b440b8073310acd06Douglas Gregor Self.ConcurrencyCheckValue = CheckLocked; 224bdf6062bc10aa3b73b16402b440b8073310acd06Douglas Gregor } 225bdf6062bc10aa3b73b16402b440b8073310acd06Douglas Gregor 226bdf6062bc10aa3b73b16402b440b8073310acd06Douglas Gregor ~ConcurrencyCheck() { 227bdf6062bc10aa3b73b16402b440b8073310acd06Douglas Gregor Self.ConcurrencyCheckValue = CheckUnlocked; 228bdf6062bc10aa3b73b16402b440b8073310acd06Douglas Gregor } 229bdf6062bc10aa3b73b16402b440b8073310acd06Douglas Gregor }; 230bdf6062bc10aa3b73b16402b440b8073310acd06Douglas Gregor friend class ConcurrencyCheck; 231bdf6062bc10aa3b73b16402b440b8073310acd06Douglas Gregor 2320853a02c3b04d96a3c432b883e403175c954cd81Argyrios Kyrtzidis ~ASTUnit(); 2330853a02c3b04d96a3c432b883e403175c954cd81Argyrios Kyrtzidis 234c7822dbf3c01a2a5f837cff82ba7889ea755dacaDaniel Dunbar bool isMainFileAST() const { return MainFileIsAST; } 235c7822dbf3c01a2a5f837cff82ba7889ea755dacaDaniel Dunbar 2363687e9d3a5dbfa9963af02a49a2b139d91310813Douglas Gregor const Diagnostic &getDiagnostics() const { return *Diagnostics; } 2373687e9d3a5dbfa9963af02a49a2b139d91310813Douglas Gregor Diagnostic &getDiagnostics() { return *Diagnostics; } 2383687e9d3a5dbfa9963af02a49a2b139d91310813Douglas Gregor 239405634b215f19eec7183bd8005e34aa5a02f64a1Douglas Gregor const SourceManager &getSourceManager() const { return *SourceMgr; } 240405634b215f19eec7183bd8005e34aa5a02f64a1Douglas Gregor SourceManager &getSourceManager() { return *SourceMgr; } 2410853a02c3b04d96a3c432b883e403175c954cd81Argyrios Kyrtzidis 2420853a02c3b04d96a3c432b883e403175c954cd81Argyrios Kyrtzidis const Preprocessor &getPreprocessor() const { return *PP.get(); } 2430853a02c3b04d96a3c432b883e403175c954cd81Argyrios Kyrtzidis Preprocessor &getPreprocessor() { return *PP.get(); } 2441eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 2450853a02c3b04d96a3c432b883e403175c954cd81Argyrios Kyrtzidis const ASTContext &getASTContext() const { return *Ctx.get(); } 2460853a02c3b04d96a3c432b883e403175c954cd81Argyrios Kyrtzidis ASTContext &getASTContext() { return *Ctx.get(); } 2470853a02c3b04d96a3c432b883e403175c954cd81Argyrios Kyrtzidis 248405634b215f19eec7183bd8005e34aa5a02f64a1Douglas Gregor const FileManager &getFileManager() const { return *FileMgr; } 249405634b215f19eec7183bd8005e34aa5a02f64a1Douglas Gregor FileManager &getFileManager() { return *FileMgr; } 250f772d1e2a5688572d07f42896a50ac57a4a41fe8Daniel Dunbar 25177accc11f04ed4ff9afd4e27d430144d4714be56Steve Naroff const std::string &getOriginalSourceFileName(); 252e19944c93961b7618f4f3f3185f698f46369ea54Steve Naroff const std::string &getPCHFileName(); 253b85bca2676b433ae555db09de4dd2823ff13b856Zhongxing Xu 254313e26c4e81f0e467490a530548450f4c824a6c4Douglas Gregor /// \brief Add a temporary file that the ASTUnit depends on. 255313e26c4e81f0e467490a530548450f4c824a6c4Douglas Gregor /// 256313e26c4e81f0e467490a530548450f4c824a6c4Douglas Gregor /// This file will be erased when the ASTUnit is destroyed. 257313e26c4e81f0e467490a530548450f4c824a6c4Douglas Gregor void addTemporaryFile(const llvm::sys::Path &TempFile) { 258313e26c4e81f0e467490a530548450f4c824a6c4Douglas Gregor TemporaryFiles.push_back(TempFile); 259313e26c4e81f0e467490a530548450f4c824a6c4Douglas Gregor } 260313e26c4e81f0e467490a530548450f4c824a6c4Douglas Gregor 2617d1d49d2971b20a97b3c2a301470b9eaaa130137Douglas Gregor bool getOnlyLocalDecls() const { return OnlyLocalDecls; } 262f772d1e2a5688572d07f42896a50ac57a4a41fe8Daniel Dunbar 263eb8837b88c18631c69ac75f64ab1853762063180Douglas Gregor /// \brief Retrieve the maximum PCH level of declarations that a 264eb8837b88c18631c69ac75f64ab1853762063180Douglas Gregor /// traversal of the translation unit should consider. 265eb8837b88c18631c69ac75f64ab1853762063180Douglas Gregor unsigned getMaxPCHLevel() const; 266eb8837b88c18631c69ac75f64ab1853762063180Douglas Gregor 267f96b524306ccfa623235d375deee79637bd38f29Steve Naroff void setLastASTLocation(ASTLocation ALoc) { LastLoc = ALoc; } 268f96b524306ccfa623235d375deee79637bd38f29Steve Naroff ASTLocation getLastASTLocation() const { return LastLoc; } 269f772d1e2a5688572d07f42896a50ac57a4a41fe8Daniel Dunbar 270eb8837b88c18631c69ac75f64ab1853762063180Douglas Gregor typedef std::vector<Decl *>::iterator top_level_iterator; 271eb8837b88c18631c69ac75f64ab1853762063180Douglas Gregor 272eb8837b88c18631c69ac75f64ab1853762063180Douglas Gregor top_level_iterator top_level_begin() { 273f772d1e2a5688572d07f42896a50ac57a4a41fe8Daniel Dunbar assert(!isMainFileAST() && "Invalid call for AST based ASTUnit!"); 274eb8837b88c18631c69ac75f64ab1853762063180Douglas Gregor if (!TopLevelDeclsInPreamble.empty()) 275eb8837b88c18631c69ac75f64ab1853762063180Douglas Gregor RealizeTopLevelDeclsFromPreamble(); 276eb8837b88c18631c69ac75f64ab1853762063180Douglas Gregor return TopLevelDecls.begin(); 277f772d1e2a5688572d07f42896a50ac57a4a41fe8Daniel Dunbar } 278eb8837b88c18631c69ac75f64ab1853762063180Douglas Gregor 279eb8837b88c18631c69ac75f64ab1853762063180Douglas Gregor top_level_iterator top_level_end() { 280f772d1e2a5688572d07f42896a50ac57a4a41fe8Daniel Dunbar assert(!isMainFileAST() && "Invalid call for AST based ASTUnit!"); 281eb8837b88c18631c69ac75f64ab1853762063180Douglas Gregor if (!TopLevelDeclsInPreamble.empty()) 282eb8837b88c18631c69ac75f64ab1853762063180Douglas Gregor RealizeTopLevelDeclsFromPreamble(); 283eb8837b88c18631c69ac75f64ab1853762063180Douglas Gregor return TopLevelDecls.end(); 284eb8837b88c18631c69ac75f64ab1853762063180Douglas Gregor } 285eb8837b88c18631c69ac75f64ab1853762063180Douglas Gregor 286eb8837b88c18631c69ac75f64ab1853762063180Douglas Gregor std::size_t top_level_size() const { 287eb8837b88c18631c69ac75f64ab1853762063180Douglas Gregor assert(!isMainFileAST() && "Invalid call for AST based ASTUnit!"); 288eb8837b88c18631c69ac75f64ab1853762063180Douglas Gregor return TopLevelDeclsInPreamble.size() + TopLevelDecls.size(); 289eb8837b88c18631c69ac75f64ab1853762063180Douglas Gregor } 290eb8837b88c18631c69ac75f64ab1853762063180Douglas Gregor 291eb8837b88c18631c69ac75f64ab1853762063180Douglas Gregor bool top_level_empty() const { 292eb8837b88c18631c69ac75f64ab1853762063180Douglas Gregor assert(!isMainFileAST() && "Invalid call for AST based ASTUnit!"); 293eb8837b88c18631c69ac75f64ab1853762063180Douglas Gregor return TopLevelDeclsInPreamble.empty() && TopLevelDecls.empty(); 294eb8837b88c18631c69ac75f64ab1853762063180Douglas Gregor } 295eb8837b88c18631c69ac75f64ab1853762063180Douglas Gregor 296eb8837b88c18631c69ac75f64ab1853762063180Douglas Gregor /// \brief Add a new top-level declaration. 297eb8837b88c18631c69ac75f64ab1853762063180Douglas Gregor void addTopLevelDecl(Decl *D) { 298eb8837b88c18631c69ac75f64ab1853762063180Douglas Gregor TopLevelDecls.push_back(D); 299eb8837b88c18631c69ac75f64ab1853762063180Douglas Gregor } 300eb8837b88c18631c69ac75f64ab1853762063180Douglas Gregor 301eb8837b88c18631c69ac75f64ab1853762063180Douglas Gregor /// \brief Add a new top-level declaration, identified by its ID in 302eb8837b88c18631c69ac75f64ab1853762063180Douglas Gregor /// the precompiled preamble. 303eb8837b88c18631c69ac75f64ab1853762063180Douglas Gregor void addTopLevelDeclFromPreamble(pch::DeclID D) { 304eb8837b88c18631c69ac75f64ab1853762063180Douglas Gregor TopLevelDeclsInPreamble.push_back(D); 305f772d1e2a5688572d07f42896a50ac57a4a41fe8Daniel Dunbar } 306f772d1e2a5688572d07f42896a50ac57a4a41fe8Daniel Dunbar 307788f5a1242c04762f91eaa7565c07b9865846d88Douglas Gregor /// \brief Retrieve the mapping from File IDs to the preprocessed entities 308788f5a1242c04762f91eaa7565c07b9865846d88Douglas Gregor /// within that file. 309788f5a1242c04762f91eaa7565c07b9865846d88Douglas Gregor PreprocessedEntitiesByFileMap &getPreprocessedEntitiesByFile() { 310788f5a1242c04762f91eaa7565c07b9865846d88Douglas Gregor return PreprocessedEntitiesByFile; 311788f5a1242c04762f91eaa7565c07b9865846d88Douglas Gregor } 312788f5a1242c04762f91eaa7565c07b9865846d88Douglas Gregor 313a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas Gregor // Retrieve the diagnostics associated with this AST 314405634b215f19eec7183bd8005e34aa5a02f64a1Douglas Gregor typedef const StoredDiagnostic *stored_diag_iterator; 315405634b215f19eec7183bd8005e34aa5a02f64a1Douglas Gregor stored_diag_iterator stored_diag_begin() const { 316405634b215f19eec7183bd8005e34aa5a02f64a1Douglas Gregor return StoredDiagnostics.begin(); 317405634b215f19eec7183bd8005e34aa5a02f64a1Douglas Gregor } 318405634b215f19eec7183bd8005e34aa5a02f64a1Douglas Gregor stored_diag_iterator stored_diag_end() const { 319405634b215f19eec7183bd8005e34aa5a02f64a1Douglas Gregor return StoredDiagnostics.end(); 320405634b215f19eec7183bd8005e34aa5a02f64a1Douglas Gregor } 321405634b215f19eec7183bd8005e34aa5a02f64a1Douglas Gregor unsigned stored_diag_size() const { return StoredDiagnostics.size(); } 322405634b215f19eec7183bd8005e34aa5a02f64a1Douglas Gregor 323405634b215f19eec7183bd8005e34aa5a02f64a1Douglas Gregor llvm::SmallVector<StoredDiagnostic, 4> &getStoredDiagnostics() { 324405634b215f19eec7183bd8005e34aa5a02f64a1Douglas Gregor return StoredDiagnostics; 325a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas Gregor } 326a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas Gregor 327df95a13ec73d2cdaea79555cb412d767f4963120Douglas Gregor /// \brief Whether this AST represents a complete translation unit. 328df95a13ec73d2cdaea79555cb412d767f4963120Douglas Gregor /// 329df95a13ec73d2cdaea79555cb412d767f4963120Douglas Gregor /// If false, this AST is only a partial translation unit, e.g., one 330df95a13ec73d2cdaea79555cb412d767f4963120Douglas Gregor /// that might still be used as a precompiled header or preamble. 331df95a13ec73d2cdaea79555cb412d767f4963120Douglas Gregor bool isCompleteTranslationUnit() const { return CompleteTranslationUnit; } 332df95a13ec73d2cdaea79555cb412d767f4963120Douglas Gregor 3334db64a461cb3442934afe43c83ed3f17f7c11c1dDouglas Gregor /// \brief A mapping from a file name to the memory buffer that stores the 3344db64a461cb3442934afe43c83ed3f17f7c11c1dDouglas Gregor /// remapped contents of that file. 3354db64a461cb3442934afe43c83ed3f17f7c11c1dDouglas Gregor typedef std::pair<std::string, const llvm::MemoryBuffer *> RemappedFile; 3364db64a461cb3442934afe43c83ed3f17f7c11c1dDouglas Gregor 3370853a02c3b04d96a3c432b883e403175c954cd81Argyrios Kyrtzidis /// \brief Create a ASTUnit from a PCH file. 3380853a02c3b04d96a3c432b883e403175c954cd81Argyrios Kyrtzidis /// 33931b87d8006d4863dd9b17e515ac720941efc38e3Daniel Dunbar /// \param Filename - The PCH file to load. 3400853a02c3b04d96a3c432b883e403175c954cd81Argyrios Kyrtzidis /// 3415262fda30b876c8aae95f2eb92e349418d6b14bbDaniel Dunbar /// \param Diags - The diagnostics engine to use for reporting errors; its 3425262fda30b876c8aae95f2eb92e349418d6b14bbDaniel Dunbar /// lifetime is expected to extend past that of the returned ASTUnit. 34331b87d8006d4863dd9b17e515ac720941efc38e3Daniel Dunbar /// 34431b87d8006d4863dd9b17e515ac720941efc38e3Daniel Dunbar /// \returns - The initialized ASTUnit or null if the PCH failed to load. 3450853a02c3b04d96a3c432b883e403175c954cd81Argyrios Kyrtzidis static ASTUnit *LoadFromPCHFile(const std::string &Filename, 34628019772db70d4547be05a042eb950bc910f134fDouglas Gregor llvm::IntrusiveRefCntPtr<Diagnostic> Diags, 3475cf48766d626ff6b223acc9d4b7e415ca8480836Ted Kremenek bool OnlyLocalDecls = false, 3484db64a461cb3442934afe43c83ed3f17f7c11c1dDouglas Gregor RemappedFile *RemappedFiles = 0, 349a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas Gregor unsigned NumRemappedFiles = 0, 350a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas Gregor bool CaptureDiagnostics = false); 351521bf9c529e653ab28896d027352d3e16e2672d5Daniel Dunbar 352521bf9c529e653ab28896d027352d3e16e2672d5Daniel Dunbar /// LoadFromCompilerInvocation - Create an ASTUnit from a source file, via a 353521bf9c529e653ab28896d027352d3e16e2672d5Daniel Dunbar /// CompilerInvocation object. 354521bf9c529e653ab28896d027352d3e16e2672d5Daniel Dunbar /// 355521bf9c529e653ab28896d027352d3e16e2672d5Daniel Dunbar /// \param CI - The compiler invocation to use; it must have exactly one input 356f7acc37450d59ef751df73acb91de73850cc6517Daniel Dunbar /// source file. The ASTUnit takes ownership of the CompilerInvocation object. 357521bf9c529e653ab28896d027352d3e16e2672d5Daniel Dunbar /// 3585262fda30b876c8aae95f2eb92e349418d6b14bbDaniel Dunbar /// \param Diags - The diagnostics engine to use for reporting errors; its 3595262fda30b876c8aae95f2eb92e349418d6b14bbDaniel Dunbar /// lifetime is expected to extend past that of the returned ASTUnit. 360521bf9c529e653ab28896d027352d3e16e2672d5Daniel Dunbar // 361521bf9c529e653ab28896d027352d3e16e2672d5Daniel Dunbar // FIXME: Move OnlyLocalDecls, UseBumpAllocator to setters on the ASTUnit, we 362521bf9c529e653ab28896d027352d3e16e2672d5Daniel Dunbar // shouldn't need to specify them at construction time. 363f7acc37450d59ef751df73acb91de73850cc6517Daniel Dunbar static ASTUnit *LoadFromCompilerInvocation(CompilerInvocation *CI, 36428019772db70d4547be05a042eb950bc910f134fDouglas Gregor llvm::IntrusiveRefCntPtr<Diagnostic> Diags, 365a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas Gregor bool OnlyLocalDecls = false, 36644c181aec37789f25f6c15543c164416f72e562aDouglas Gregor bool CaptureDiagnostics = false, 367df95a13ec73d2cdaea79555cb412d767f4963120Douglas Gregor bool PrecompilePreamble = false, 368df95a13ec73d2cdaea79555cb412d767f4963120Douglas Gregor bool CompleteTranslationUnit = true); 369521bf9c529e653ab28896d027352d3e16e2672d5Daniel Dunbar 3707b55668db7618334cc40011d3c1e128524d89462Daniel Dunbar /// LoadFromCommandLine - Create an ASTUnit from a vector of command line 3717b55668db7618334cc40011d3c1e128524d89462Daniel Dunbar /// arguments, which must specify exactly one source file. 3727b55668db7618334cc40011d3c1e128524d89462Daniel Dunbar /// 3737b55668db7618334cc40011d3c1e128524d89462Daniel Dunbar /// \param ArgBegin - The beginning of the argument vector. 3747b55668db7618334cc40011d3c1e128524d89462Daniel Dunbar /// 3757b55668db7618334cc40011d3c1e128524d89462Daniel Dunbar /// \param ArgEnd - The end of the argument vector. 3767b55668db7618334cc40011d3c1e128524d89462Daniel Dunbar /// 3775262fda30b876c8aae95f2eb92e349418d6b14bbDaniel Dunbar /// \param Diags - The diagnostics engine to use for reporting errors; its 3785262fda30b876c8aae95f2eb92e349418d6b14bbDaniel Dunbar /// lifetime is expected to extend past that of the returned ASTUnit. 3797b55668db7618334cc40011d3c1e128524d89462Daniel Dunbar /// 380869824e87940f97b87064db2df2861e82e08a8c6Daniel Dunbar /// \param ResourceFilesPath - The path to the compiler resource files. 3817b55668db7618334cc40011d3c1e128524d89462Daniel Dunbar // 3827b55668db7618334cc40011d3c1e128524d89462Daniel Dunbar // FIXME: Move OnlyLocalDecls, UseBumpAllocator to setters on the ASTUnit, we 3837b55668db7618334cc40011d3c1e128524d89462Daniel Dunbar // shouldn't need to specify them at construction time. 3847b55668db7618334cc40011d3c1e128524d89462Daniel Dunbar static ASTUnit *LoadFromCommandLine(const char **ArgBegin, 3857b55668db7618334cc40011d3c1e128524d89462Daniel Dunbar const char **ArgEnd, 38628019772db70d4547be05a042eb950bc910f134fDouglas Gregor llvm::IntrusiveRefCntPtr<Diagnostic> Diags, 387869824e87940f97b87064db2df2861e82e08a8c6Daniel Dunbar llvm::StringRef ResourceFilesPath, 3887b55668db7618334cc40011d3c1e128524d89462Daniel Dunbar bool OnlyLocalDecls = false, 3894db64a461cb3442934afe43c83ed3f17f7c11c1dDouglas Gregor RemappedFile *RemappedFiles = 0, 390a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas Gregor unsigned NumRemappedFiles = 0, 39144c181aec37789f25f6c15543c164416f72e562aDouglas Gregor bool CaptureDiagnostics = false, 392df95a13ec73d2cdaea79555cb412d767f4963120Douglas Gregor bool PrecompilePreamble = false, 393df95a13ec73d2cdaea79555cb412d767f4963120Douglas Gregor bool CompleteTranslationUnit = true); 394abc563f554951259bbe0315055cad92ee14d87e4Douglas Gregor 395abc563f554951259bbe0315055cad92ee14d87e4Douglas Gregor /// \brief Reparse the source files using the same command-line options that 396abc563f554951259bbe0315055cad92ee14d87e4Douglas Gregor /// were originally used to produce this translation unit. 397abc563f554951259bbe0315055cad92ee14d87e4Douglas Gregor /// 398abc563f554951259bbe0315055cad92ee14d87e4Douglas Gregor /// \returns True if a failure occurred that causes the ASTUnit not to 399abc563f554951259bbe0315055cad92ee14d87e4Douglas Gregor /// contain any translation-unit information, false otherwise. 400abc563f554951259bbe0315055cad92ee14d87e4Douglas Gregor bool Reparse(RemappedFile *RemappedFiles = 0, 401abc563f554951259bbe0315055cad92ee14d87e4Douglas Gregor unsigned NumRemappedFiles = 0); 4021abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor 4031abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor /// \brief Perform code completion at the given file, line, and 4041abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor /// column within this translation unit. 4051abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor /// 406cee235cdf0b8047761ffac598c4c3a32ab7411a2Douglas Gregor /// \param File The file in which code completion will occur. 407cee235cdf0b8047761ffac598c4c3a32ab7411a2Douglas Gregor /// 408cee235cdf0b8047761ffac598c4c3a32ab7411a2Douglas Gregor /// \param Line The line at which code completion will occur. 409cee235cdf0b8047761ffac598c4c3a32ab7411a2Douglas Gregor /// 410cee235cdf0b8047761ffac598c4c3a32ab7411a2Douglas Gregor /// \param Column The column at which code completion will occur. 411cee235cdf0b8047761ffac598c4c3a32ab7411a2Douglas Gregor /// 412cee235cdf0b8047761ffac598c4c3a32ab7411a2Douglas Gregor /// \param IncludeMacros Whether to include macros in the code-completion 413cee235cdf0b8047761ffac598c4c3a32ab7411a2Douglas Gregor /// results. 414cee235cdf0b8047761ffac598c4c3a32ab7411a2Douglas Gregor /// 415cee235cdf0b8047761ffac598c4c3a32ab7411a2Douglas Gregor /// \param IncludeCodePatterns Whether to include code patterns (such as a 416cee235cdf0b8047761ffac598c4c3a32ab7411a2Douglas Gregor /// for loop) in the code-completion results. 4171abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor /// 4181abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor /// FIXME: The Diag, LangOpts, SourceMgr, FileMgr, and 4191abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor /// StoredDiagnostics parameters are all disgusting hacks. They will 4201abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor /// go away. 4211abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor void CodeComplete(llvm::StringRef File, unsigned Line, unsigned Column, 4221abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor RemappedFile *RemappedFiles, unsigned NumRemappedFiles, 423cee235cdf0b8047761ffac598c4c3a32ab7411a2Douglas Gregor bool IncludeMacros, bool IncludeCodePatterns, 4241abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor CodeCompleteConsumer &Consumer, 4251abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor Diagnostic &Diag, LangOptions &LangOpts, 4261abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor SourceManager &SourceMgr, FileManager &FileMgr, 4271abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor llvm::SmallVectorImpl<StoredDiagnostic> &StoredDiagnostics); 4280853a02c3b04d96a3c432b883e403175c954cd81Argyrios Kyrtzidis}; 4290853a02c3b04d96a3c432b883e403175c954cd81Argyrios Kyrtzidis 4300853a02c3b04d96a3c432b883e403175c954cd81Argyrios Kyrtzidis} // namespace clang 4310853a02c3b04d96a3c432b883e403175c954cd81Argyrios Kyrtzidis 4320853a02c3b04d96a3c432b883e403175c954cd81Argyrios Kyrtzidis#endif 433