ASTReader.h revision ca2ab45341c448284cf93770018c717810575f86
1//===--- ASTReader.h - AST File Reader --------------------------*- 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// This file defines the ASTReader class, which reads AST files. 11// 12//===----------------------------------------------------------------------===// 13 14#ifndef LLVM_CLANG_FRONTEND_AST_READER_H 15#define LLVM_CLANG_FRONTEND_AST_READER_H 16 17#include "clang/AST/DeclObjC.h" 18#include "clang/AST/DeclarationName.h" 19#include "clang/AST/TemplateBase.h" 20#include "clang/Basic/Diagnostic.h" 21#include "clang/Basic/FileManager.h" 22#include "clang/Basic/FileSystemOptions.h" 23#include "clang/Basic/IdentifierTable.h" 24#include "clang/Basic/SourceManager.h" 25#include "clang/Lex/ExternalPreprocessorSource.h" 26#include "clang/Lex/HeaderSearch.h" 27#include "clang/Lex/PPMutationListener.h" 28#include "clang/Lex/PreprocessingRecord.h" 29#include "clang/Sema/ExternalSemaSource.h" 30#include "clang/Serialization/ASTBitCodes.h" 31#include "clang/Serialization/ContinuousRangeMap.h" 32#include "clang/Serialization/Module.h" 33#include "clang/Serialization/ModuleManager.h" 34#include "llvm/ADT/APFloat.h" 35#include "llvm/ADT/APInt.h" 36#include "llvm/ADT/APSInt.h" 37#include "llvm/ADT/DenseSet.h" 38#include "llvm/ADT/MapVector.h" 39#include "llvm/ADT/OwningPtr.h" 40#include "llvm/ADT/SmallPtrSet.h" 41#include "llvm/ADT/SmallSet.h" 42#include "llvm/ADT/SmallVector.h" 43#include "llvm/ADT/StringRef.h" 44#include "llvm/Bitcode/BitstreamReader.h" 45#include "llvm/Support/DataTypes.h" 46#include <deque> 47#include <map> 48#include <string> 49#include <utility> 50#include <vector> 51 52namespace llvm { 53 class MemoryBuffer; 54} 55 56namespace clang { 57 58class AddrLabelExpr; 59class ASTConsumer; 60class ASTContext; 61class ASTIdentifierIterator; 62class ASTUnit; // FIXME: Layering violation and egregious hack. 63class Attr; 64class Decl; 65class DeclContext; 66class DiagnosticOptions; 67class NestedNameSpecifier; 68class CXXBaseSpecifier; 69class CXXConstructorDecl; 70class CXXCtorInitializer; 71class GotoStmt; 72class MacroDefinition; 73class NamedDecl; 74class OpaqueValueExpr; 75class Preprocessor; 76class PreprocessorOptions; 77class Sema; 78class SwitchCase; 79class ASTDeserializationListener; 80class ASTWriter; 81class ASTReader; 82class ASTDeclReader; 83class ASTStmtReader; 84class TypeLocReader; 85struct HeaderFileInfo; 86class VersionTuple; 87class TargetOptions; 88class ASTUnresolvedSet; 89 90/// \brief Abstract interface for callback invocations by the ASTReader. 91/// 92/// While reading an AST file, the ASTReader will call the methods of the 93/// listener to pass on specific information. Some of the listener methods can 94/// return true to indicate to the ASTReader that the information (and 95/// consequently the AST file) is invalid. 96class ASTReaderListener { 97public: 98 virtual ~ASTReaderListener(); 99 100 /// \brief Receives the language options. 101 /// 102 /// \returns true to indicate the options are invalid or false otherwise. 103 virtual bool ReadLanguageOptions(const LangOptions &LangOpts, 104 bool Complain) { 105 return false; 106 } 107 108 /// \brief Receives the target options. 109 /// 110 /// \returns true to indicate the target options are invalid, or false 111 /// otherwise. 112 virtual bool ReadTargetOptions(const TargetOptions &TargetOpts, 113 bool Complain) { 114 return false; 115 } 116 117 /// \brief Receives the diagnostic options. 118 /// 119 /// \returns true to indicate the diagnostic options are invalid, or false 120 /// otherwise. 121 virtual bool ReadDiagnosticOptions(const DiagnosticOptions &DiagOpts, 122 bool Complain) { 123 return false; 124 } 125 126 /// \brief Receives the file system options. 127 /// 128 /// \returns true to indicate the file system options are invalid, or false 129 /// otherwise. 130 virtual bool ReadFileSystemOptions(const FileSystemOptions &FSOpts, 131 bool Complain) { 132 return false; 133 } 134 135 /// \brief Receives the header search options. 136 /// 137 /// \returns true to indicate the header search options are invalid, or false 138 /// otherwise. 139 virtual bool ReadHeaderSearchOptions(const HeaderSearchOptions &HSOpts, 140 bool Complain) { 141 return false; 142 } 143 144 /// \brief Receives the preprocessor options. 145 /// 146 /// \param SuggestedPredefines Can be filled in with the set of predefines 147 /// that are suggested by the preprocessor options. Typically only used when 148 /// loading a precompiled header. 149 /// 150 /// \returns true to indicate the preprocessor options are invalid, or false 151 /// otherwise. 152 virtual bool ReadPreprocessorOptions(const PreprocessorOptions &PPOpts, 153 bool Complain, 154 std::string &SuggestedPredefines) { 155 return false; 156 } 157 158 /// \brief Receives a HeaderFileInfo entry. 159 virtual void ReadHeaderFileInfo(const HeaderFileInfo &HFI, unsigned ID) {} 160 161 /// \brief Receives __COUNTER__ value. 162 virtual void ReadCounter(const serialization::ModuleFile &M, 163 unsigned Value) {} 164}; 165 166/// \brief ASTReaderListener implementation to validate the information of 167/// the PCH file against an initialized Preprocessor. 168class PCHValidator : public ASTReaderListener { 169 Preprocessor &PP; 170 ASTReader &Reader; 171 172 unsigned NumHeaderInfos; 173 174public: 175 PCHValidator(Preprocessor &PP, ASTReader &Reader) 176 : PP(PP), Reader(Reader), NumHeaderInfos(0) {} 177 178 virtual bool ReadLanguageOptions(const LangOptions &LangOpts, 179 bool Complain); 180 virtual bool ReadTargetOptions(const TargetOptions &TargetOpts, 181 bool Complain); 182 virtual bool ReadPreprocessorOptions(const PreprocessorOptions &PPOpts, 183 bool Complain, 184 std::string &SuggestedPredefines); 185 virtual void ReadHeaderFileInfo(const HeaderFileInfo &HFI, unsigned ID); 186 virtual void ReadCounter(const serialization::ModuleFile &M, unsigned Value); 187 188private: 189 void Error(const char *Msg); 190}; 191 192namespace serialization { 193 194class ReadMethodPoolVisitor; 195 196namespace reader { 197 class ASTIdentifierLookupTrait; 198 /// \brief The on-disk hash table used for the DeclContext's Name lookup table. 199 typedef OnDiskChainedHashTable<ASTDeclContextNameLookupTrait> 200 ASTDeclContextNameLookupTable; 201} 202 203} // end namespace serialization 204 205/// \brief Reads an AST files chain containing the contents of a translation 206/// unit. 207/// 208/// The ASTReader class reads bitstreams (produced by the ASTWriter 209/// class) containing the serialized representation of a given 210/// abstract syntax tree and its supporting data structures. An 211/// instance of the ASTReader can be attached to an ASTContext object, 212/// which will provide access to the contents of the AST files. 213/// 214/// The AST reader provides lazy de-serialization of declarations, as 215/// required when traversing the AST. Only those AST nodes that are 216/// actually required will be de-serialized. 217class ASTReader 218 : public ExternalPreprocessorSource, 219 public ExternalPreprocessingRecordSource, 220 public ExternalHeaderFileInfoSource, 221 public ExternalSemaSource, 222 public IdentifierInfoLookup, 223 public ExternalIdentifierLookup, 224 public ExternalSLocEntrySource 225{ 226public: 227 typedef SmallVector<uint64_t, 64> RecordData; 228 229 /// \brief The result of reading the control block of an AST file, which 230 /// can fail for various reasons. 231 enum ASTReadResult { 232 /// \brief The control block was read successfully. Aside from failures, 233 /// the AST file is safe to read into the current context. 234 Success, 235 /// \brief The AST file itself appears corrupted. 236 Failure, 237 /// \brief The AST file is out-of-date relative to its input files, 238 /// and needs to be regenerated. 239 OutOfDate, 240 /// \brief The AST file was written by a different version of Clang. 241 VersionMismatch, 242 /// \brief The AST file was writtten with a different language/target 243 /// configuration. 244 ConfigurationMismatch, 245 /// \brief The AST file has errors. 246 HadErrors 247 }; 248 249 /// \brief Types of AST files. 250 friend class PCHValidator; 251 friend class ASTDeclReader; 252 friend class ASTStmtReader; 253 friend class ASTIdentifierIterator; 254 friend class serialization::reader::ASTIdentifierLookupTrait; 255 friend class TypeLocReader; 256 friend class ASTWriter; 257 friend class ASTUnit; // ASTUnit needs to remap source locations. 258 friend class serialization::ReadMethodPoolVisitor; 259 260 typedef serialization::ModuleFile ModuleFile; 261 typedef serialization::ModuleKind ModuleKind; 262 typedef serialization::ModuleManager ModuleManager; 263 264 typedef ModuleManager::ModuleIterator ModuleIterator; 265 typedef ModuleManager::ModuleConstIterator ModuleConstIterator; 266 typedef ModuleManager::ModuleReverseIterator ModuleReverseIterator; 267 268private: 269 /// \brief The receiver of some callbacks invoked by ASTReader. 270 OwningPtr<ASTReaderListener> Listener; 271 272 /// \brief The receiver of deserialization events. 273 ASTDeserializationListener *DeserializationListener; 274 275 SourceManager &SourceMgr; 276 FileManager &FileMgr; 277 DiagnosticsEngine &Diags; 278 279 /// \brief The semantic analysis object that will be processing the 280 /// AST files and the translation unit that uses it. 281 Sema *SemaObj; 282 283 /// \brief The preprocessor that will be loading the source file. 284 Preprocessor &PP; 285 286 /// \brief The AST context into which we'll read the AST files. 287 ASTContext &Context; 288 289 /// \brief The AST consumer. 290 ASTConsumer *Consumer; 291 292 /// \brief The module manager which manages modules and their dependencies 293 ModuleManager ModuleMgr; 294 295 /// \brief A map of global bit offsets to the module that stores entities 296 /// at those bit offsets. 297 ContinuousRangeMap<uint64_t, ModuleFile*, 4> GlobalBitOffsetsMap; 298 299 /// \brief A map of negated SLocEntryIDs to the modules containing them. 300 ContinuousRangeMap<unsigned, ModuleFile*, 64> GlobalSLocEntryMap; 301 302 typedef ContinuousRangeMap<unsigned, ModuleFile*, 64> GlobalSLocOffsetMapType; 303 304 /// \brief A map of reversed (SourceManager::MaxLoadedOffset - SLocOffset) 305 /// SourceLocation offsets to the modules containing them. 306 GlobalSLocOffsetMapType GlobalSLocOffsetMap; 307 308 /// \brief Types that have already been loaded from the chain. 309 /// 310 /// When the pointer at index I is non-NULL, the type with 311 /// ID = (I + 1) << FastQual::Width has already been loaded 312 std::vector<QualType> TypesLoaded; 313 314 typedef ContinuousRangeMap<serialization::TypeID, ModuleFile *, 4> 315 GlobalTypeMapType; 316 317 /// \brief Mapping from global type IDs to the module in which the 318 /// type resides along with the offset that should be added to the 319 /// global type ID to produce a local ID. 320 GlobalTypeMapType GlobalTypeMap; 321 322 /// \brief Declarations that have already been loaded from the chain. 323 /// 324 /// When the pointer at index I is non-NULL, the declaration with ID 325 /// = I + 1 has already been loaded. 326 std::vector<Decl *> DeclsLoaded; 327 328 typedef ContinuousRangeMap<serialization::DeclID, ModuleFile *, 4> 329 GlobalDeclMapType; 330 331 /// \brief Mapping from global declaration IDs to the module in which the 332 /// declaration resides. 333 GlobalDeclMapType GlobalDeclMap; 334 335 typedef std::pair<ModuleFile *, uint64_t> FileOffset; 336 typedef SmallVector<FileOffset, 2> FileOffsetsTy; 337 typedef llvm::DenseMap<serialization::DeclID, FileOffsetsTy> 338 DeclUpdateOffsetsMap; 339 340 /// \brief Declarations that have modifications residing in a later file 341 /// in the chain. 342 DeclUpdateOffsetsMap DeclUpdateOffsets; 343 344 struct ReplacedDeclInfo { 345 ModuleFile *Mod; 346 uint64_t Offset; 347 unsigned RawLoc; 348 349 ReplacedDeclInfo() : Mod(0), Offset(0), RawLoc(0) {} 350 ReplacedDeclInfo(ModuleFile *Mod, uint64_t Offset, unsigned RawLoc) 351 : Mod(Mod), Offset(Offset), RawLoc(RawLoc) {} 352 }; 353 354 typedef llvm::DenseMap<serialization::DeclID, ReplacedDeclInfo> 355 DeclReplacementMap; 356 /// \brief Declarations that have been replaced in a later file in the chain. 357 DeclReplacementMap ReplacedDecls; 358 359 struct FileDeclsInfo { 360 ModuleFile *Mod; 361 ArrayRef<serialization::LocalDeclID> Decls; 362 363 FileDeclsInfo() : Mod(0) {} 364 FileDeclsInfo(ModuleFile *Mod, ArrayRef<serialization::LocalDeclID> Decls) 365 : Mod(Mod), Decls(Decls) {} 366 }; 367 368 /// \brief Map from a FileID to the file-level declarations that it contains. 369 llvm::DenseMap<FileID, FileDeclsInfo> FileDeclIDs; 370 371 // Updates for visible decls can occur for other contexts than just the 372 // TU, and when we read those update records, the actual context will not 373 // be available yet (unless it's the TU), so have this pending map using the 374 // ID as a key. It will be realized when the context is actually loaded. 375 typedef 376 SmallVector<std::pair<serialization::reader::ASTDeclContextNameLookupTable *, 377 ModuleFile*>, 1> DeclContextVisibleUpdates; 378 typedef llvm::DenseMap<serialization::DeclID, DeclContextVisibleUpdates> 379 DeclContextVisibleUpdatesPending; 380 381 /// \brief Updates to the visible declarations of declaration contexts that 382 /// haven't been loaded yet. 383 DeclContextVisibleUpdatesPending PendingVisibleUpdates; 384 385 /// \brief The set of C++ or Objective-C classes that have forward 386 /// declarations that have not yet been linked to their definitions. 387 llvm::SmallPtrSet<Decl *, 4> PendingDefinitions; 388 389 typedef llvm::MapVector<Decl *, uint64_t, 390 llvm::SmallDenseMap<Decl *, unsigned, 4>, 391 llvm::SmallVector<std::pair<Decl *, uint64_t>, 4> > 392 PendingBodiesMap; 393 394 /// \brief Functions or methods that have bodies that will be attached. 395 PendingBodiesMap PendingBodies; 396 397 /// \brief Read the records that describe the contents of declcontexts. 398 bool ReadDeclContextStorage(ModuleFile &M, 399 llvm::BitstreamCursor &Cursor, 400 const std::pair<uint64_t, uint64_t> &Offsets, 401 serialization::DeclContextInfo &Info); 402 403 /// \brief A vector containing identifiers that have already been 404 /// loaded. 405 /// 406 /// If the pointer at index I is non-NULL, then it refers to the 407 /// IdentifierInfo for the identifier with ID=I+1 that has already 408 /// been loaded. 409 std::vector<IdentifierInfo *> IdentifiersLoaded; 410 411 typedef ContinuousRangeMap<serialization::IdentID, ModuleFile *, 4> 412 GlobalIdentifierMapType; 413 414 /// \brief Mapping from global identifier IDs to the module in which the 415 /// identifier resides along with the offset that should be added to the 416 /// global identifier ID to produce a local ID. 417 GlobalIdentifierMapType GlobalIdentifierMap; 418 419 /// \brief A vector containing macros that have already been 420 /// loaded. 421 /// 422 /// If the pointer at index I is non-NULL, then it refers to the 423 /// MacroInfo for the identifier with ID=I+1 that has already 424 /// been loaded. 425 std::vector<MacroInfo *> MacrosLoaded; 426 427 typedef ContinuousRangeMap<serialization::MacroID, ModuleFile *, 4> 428 GlobalMacroMapType; 429 430 /// \brief Mapping from global macro IDs to the module in which the 431 /// macro resides along with the offset that should be added to the 432 /// global macro ID to produce a local ID. 433 GlobalMacroMapType GlobalMacroMap; 434 435 typedef llvm::DenseMap<serialization::MacroID, 436 llvm::SmallVector<std::pair<serialization::SubmoduleID, 437 MacroUpdate>, 1> > 438 MacroUpdatesMap; 439 440 /// \brief Mapping from (global) macro IDs to the set of updates to be 441 /// performed to the corresponding macro. 442 MacroUpdatesMap MacroUpdates; 443 444 /// \brief A vector containing submodules that have already been loaded. 445 /// 446 /// This vector is indexed by the Submodule ID (-1). NULL submodule entries 447 /// indicate that the particular submodule ID has not yet been loaded. 448 SmallVector<Module *, 2> SubmodulesLoaded; 449 450 typedef ContinuousRangeMap<serialization::SubmoduleID, ModuleFile *, 4> 451 GlobalSubmoduleMapType; 452 453 /// \brief Mapping from global submodule IDs to the module file in which the 454 /// submodule resides along with the offset that should be added to the 455 /// global submodule ID to produce a local ID. 456 GlobalSubmoduleMapType GlobalSubmoduleMap; 457 458 /// \brief An entity that has been hidden. 459 class HiddenName { 460 public: 461 enum NameKind { 462 Declaration, 463 MacroVisibility, 464 MacroUndef 465 } Kind; 466 467 private: 468 unsigned Loc; 469 470 union { 471 Decl *D; 472 MacroInfo *MI; 473 }; 474 475 IdentifierInfo *Id; 476 477 public: 478 HiddenName(Decl *D) : Kind(Declaration), Loc(), D(D), Id() { } 479 480 HiddenName(IdentifierInfo *II, MacroInfo *MI) 481 : Kind(MacroVisibility), Loc(), MI(MI), Id(II) { } 482 483 HiddenName(IdentifierInfo *II, MacroInfo *MI, SourceLocation Loc) 484 : Kind(MacroUndef), Loc(Loc.getRawEncoding()), MI(MI), Id(II) { } 485 486 NameKind getKind() const { return Kind; } 487 488 Decl *getDecl() const { 489 assert(getKind() == Declaration && "Hidden name is not a declaration"); 490 return D; 491 } 492 493 std::pair<IdentifierInfo *, MacroInfo *> getMacro() const { 494 assert((getKind() == MacroUndef || getKind() == MacroVisibility) 495 && "Hidden name is not a macro!"); 496 return std::make_pair(Id, MI); 497 } 498 499 SourceLocation getMacroUndefLoc() const { 500 assert(getKind() == MacroUndef && "Hidden name is not an undef!"); 501 return SourceLocation::getFromRawEncoding(Loc); 502 } 503}; 504 505 /// \brief A set of hidden declarations. 506 typedef llvm::SmallVector<HiddenName, 2> 507 HiddenNames; 508 509 typedef llvm::DenseMap<Module *, HiddenNames> HiddenNamesMapType; 510 511 /// \brief A mapping from each of the hidden submodules to the deserialized 512 /// declarations in that submodule that could be made visible. 513 HiddenNamesMapType HiddenNamesMap; 514 515 516 /// \brief A module import or export that hasn't yet been resolved. 517 struct UnresolvedModuleImportExport { 518 /// \brief The file in which this module resides. 519 ModuleFile *File; 520 521 /// \brief The module that is importing or exporting. 522 Module *Mod; 523 524 /// \brief The local ID of the module that is being exported. 525 unsigned ID; 526 527 /// \brief Whether this is an import (vs. an export). 528 unsigned IsImport : 1; 529 530 /// \brief Whether this is a wildcard export. 531 unsigned IsWildcard : 1; 532 }; 533 534 /// \brief The set of module imports and exports that still need to be 535 /// resolved. 536 llvm::SmallVector<UnresolvedModuleImportExport, 2> 537 UnresolvedModuleImportExports; 538 539 /// \brief A vector containing selectors that have already been loaded. 540 /// 541 /// This vector is indexed by the Selector ID (-1). NULL selector 542 /// entries indicate that the particular selector ID has not yet 543 /// been loaded. 544 SmallVector<Selector, 16> SelectorsLoaded; 545 546 typedef ContinuousRangeMap<serialization::SelectorID, ModuleFile *, 4> 547 GlobalSelectorMapType; 548 549 /// \brief Mapping from global selector IDs to the module in which the 550 /// selector resides along with the offset that should be added to the 551 /// global selector ID to produce a local ID. 552 GlobalSelectorMapType GlobalSelectorMap; 553 554 /// \brief The generation number of the last time we loaded data from the 555 /// global method pool for this selector. 556 llvm::DenseMap<Selector, unsigned> SelectorGeneration; 557 558 typedef llvm::MapVector<IdentifierInfo *, 559 llvm::SmallVector<serialization::MacroID, 2> > 560 PendingMacroIDsMap; 561 562 /// \brief Mapping from identifiers that have a macro history to the global 563 /// IDs have not yet been deserialized to the global IDs of those macros. 564 PendingMacroIDsMap PendingMacroIDs; 565 566 typedef ContinuousRangeMap<unsigned, ModuleFile *, 4> 567 GlobalPreprocessedEntityMapType; 568 569 /// \brief Mapping from global preprocessing entity IDs to the module in 570 /// which the preprocessed entity resides along with the offset that should be 571 /// added to the global preprocessing entitiy ID to produce a local ID. 572 GlobalPreprocessedEntityMapType GlobalPreprocessedEntityMap; 573 574 /// \name CodeGen-relevant special data 575 /// \brief Fields containing data that is relevant to CodeGen. 576 //@{ 577 578 /// \brief The IDs of all declarations that fulfill the criteria of 579 /// "interesting" decls. 580 /// 581 /// This contains the data loaded from all EXTERNAL_DEFINITIONS blocks in the 582 /// chain. The referenced declarations are deserialized and passed to the 583 /// consumer eagerly. 584 SmallVector<uint64_t, 16> ExternalDefinitions; 585 586 /// \brief The IDs of all tentative definitions stored in the chain. 587 /// 588 /// Sema keeps track of all tentative definitions in a TU because it has to 589 /// complete them and pass them on to CodeGen. Thus, tentative definitions in 590 /// the PCH chain must be eagerly deserialized. 591 SmallVector<uint64_t, 16> TentativeDefinitions; 592 593 /// \brief The IDs of all CXXRecordDecls stored in the chain whose VTables are 594 /// used. 595 /// 596 /// CodeGen has to emit VTables for these records, so they have to be eagerly 597 /// deserialized. 598 SmallVector<uint64_t, 64> VTableUses; 599 600 /// \brief A snapshot of the pending instantiations in the chain. 601 /// 602 /// This record tracks the instantiations that Sema has to perform at the 603 /// end of the TU. It consists of a pair of values for every pending 604 /// instantiation where the first value is the ID of the decl and the second 605 /// is the instantiation location. 606 SmallVector<uint64_t, 64> PendingInstantiations; 607 608 //@} 609 610 /// \name DiagnosticsEngine-relevant special data 611 /// \brief Fields containing data that is used for generating diagnostics 612 //@{ 613 614 /// \brief A snapshot of Sema's unused file-scoped variable tracking, for 615 /// generating warnings. 616 SmallVector<uint64_t, 16> UnusedFileScopedDecls; 617 618 /// \brief A list of all the delegating constructors we've seen, to diagnose 619 /// cycles. 620 SmallVector<uint64_t, 4> DelegatingCtorDecls; 621 622 /// \brief Method selectors used in a @selector expression. Used for 623 /// implementation of -Wselector. 624 SmallVector<uint64_t, 64> ReferencedSelectorsData; 625 626 /// \brief A snapshot of Sema's weak undeclared identifier tracking, for 627 /// generating warnings. 628 SmallVector<uint64_t, 64> WeakUndeclaredIdentifiers; 629 630 /// \brief The IDs of type aliases for ext_vectors that exist in the chain. 631 /// 632 /// Used by Sema for finding sugared names for ext_vectors in diagnostics. 633 SmallVector<uint64_t, 4> ExtVectorDecls; 634 635 //@} 636 637 /// \name Sema-relevant special data 638 /// \brief Fields containing data that is used for semantic analysis 639 //@{ 640 641 /// \brief The IDs of all locally scoped extern "C" decls in the chain. 642 /// 643 /// Sema tracks these to validate that the types are consistent across all 644 /// local extern "C" declarations. 645 SmallVector<uint64_t, 16> LocallyScopedExternCDecls; 646 647 /// \brief The IDs of all dynamic class declarations in the chain. 648 /// 649 /// Sema tracks these because it checks for the key functions being defined 650 /// at the end of the TU, in which case it directs CodeGen to emit the VTable. 651 SmallVector<uint64_t, 16> DynamicClasses; 652 653 /// \brief The IDs of the declarations Sema stores directly. 654 /// 655 /// Sema tracks a few important decls, such as namespace std, directly. 656 SmallVector<uint64_t, 4> SemaDeclRefs; 657 658 /// \brief The IDs of the types ASTContext stores directly. 659 /// 660 /// The AST context tracks a few important types, such as va_list, directly. 661 SmallVector<uint64_t, 16> SpecialTypes; 662 663 /// \brief The IDs of CUDA-specific declarations ASTContext stores directly. 664 /// 665 /// The AST context tracks a few important decls, currently cudaConfigureCall, 666 /// directly. 667 SmallVector<uint64_t, 2> CUDASpecialDeclRefs; 668 669 /// \brief The floating point pragma option settings. 670 SmallVector<uint64_t, 1> FPPragmaOptions; 671 672 /// \brief The OpenCL extension settings. 673 SmallVector<uint64_t, 1> OpenCLExtensions; 674 675 /// \brief A list of the namespaces we've seen. 676 SmallVector<uint64_t, 4> KnownNamespaces; 677 678 /// \brief A list of modules that were imported by precompiled headers or 679 /// any other non-module AST file. 680 SmallVector<serialization::SubmoduleID, 2> ImportedModules; 681 //@} 682 683 /// \brief The directory that the PCH we are reading is stored in. 684 std::string CurrentDir; 685 686 /// \brief The system include root to be used when loading the 687 /// precompiled header. 688 std::string isysroot; 689 690 /// \brief Whether to disable the normal validation performed on precompiled 691 /// headers when they are loaded. 692 bool DisableValidation; 693 694 /// \brief Whether to accept an AST file with compiler errors. 695 bool AllowASTWithCompilerErrors; 696 697 /// \brief The current "generation" of the module file import stack, which 698 /// indicates how many separate module file load operations have occurred. 699 unsigned CurrentGeneration; 700 701 typedef llvm::DenseMap<unsigned, SwitchCase *> SwitchCaseMapTy; 702 /// \brief Mapping from switch-case IDs in the chain to switch-case statements 703 /// 704 /// Statements usually don't have IDs, but switch cases need them, so that the 705 /// switch statement can refer to them. 706 SwitchCaseMapTy SwitchCaseStmts; 707 708 SwitchCaseMapTy *CurrSwitchCaseStmts; 709 710 /// \brief The number of source location entries de-serialized from 711 /// the PCH file. 712 unsigned NumSLocEntriesRead; 713 714 /// \brief The number of source location entries in the chain. 715 unsigned TotalNumSLocEntries; 716 717 /// \brief The number of statements (and expressions) de-serialized 718 /// from the chain. 719 unsigned NumStatementsRead; 720 721 /// \brief The total number of statements (and expressions) stored 722 /// in the chain. 723 unsigned TotalNumStatements; 724 725 /// \brief The number of macros de-serialized from the chain. 726 unsigned NumMacrosRead; 727 728 /// \brief The total number of macros stored in the chain. 729 unsigned TotalNumMacros; 730 731 /// \brief The number of selectors that have been read. 732 unsigned NumSelectorsRead; 733 734 /// \brief The number of method pool entries that have been read. 735 unsigned NumMethodPoolEntriesRead; 736 737 /// \brief The number of times we have looked up a selector in the method 738 /// pool and not found anything interesting. 739 unsigned NumMethodPoolMisses; 740 741 /// \brief The total number of method pool entries in the selector table. 742 unsigned TotalNumMethodPoolEntries; 743 744 /// Number of lexical decl contexts read/total. 745 unsigned NumLexicalDeclContextsRead, TotalLexicalDeclContexts; 746 747 /// Number of visible decl contexts read/total. 748 unsigned NumVisibleDeclContextsRead, TotalVisibleDeclContexts; 749 750 /// Total size of modules, in bits, currently loaded 751 uint64_t TotalModulesSizeInBits; 752 753 /// \brief Number of Decl/types that are currently deserializing. 754 unsigned NumCurrentElementsDeserializing; 755 756 /// \brief Set true while we are in the process of passing deserialized 757 /// "interesting" decls to consumer inside FinishedDeserializing(). 758 /// This is used as a guard to avoid recursively repeating the process of 759 /// passing decls to consumer. 760 bool PassingDeclsToConsumer; 761 762 /// Number of CXX base specifiers currently loaded 763 unsigned NumCXXBaseSpecifiersLoaded; 764 765 /// \brief An IdentifierInfo that has been loaded but whose top-level 766 /// declarations of the same name have not (yet) been loaded. 767 struct PendingIdentifierInfo { 768 IdentifierInfo *II; 769 SmallVector<uint32_t, 4> DeclIDs; 770 }; 771 772 /// \brief The set of identifiers that were read while the AST reader was 773 /// (recursively) loading declarations. 774 /// 775 /// The declarations on the identifier chain for these identifiers will be 776 /// loaded once the recursive loading has completed. 777 std::deque<PendingIdentifierInfo> PendingIdentifierInfos; 778 779 /// \brief The generation number of each identifier, which keeps track of 780 /// the last time we loaded information about this identifier. 781 llvm::DenseMap<IdentifierInfo *, unsigned> IdentifierGeneration; 782 783 /// \brief Contains declarations and definitions that will be 784 /// "interesting" to the ASTConsumer, when we get that AST consumer. 785 /// 786 /// "Interesting" declarations are those that have data that may 787 /// need to be emitted, such as inline function definitions or 788 /// Objective-C protocols. 789 std::deque<Decl *> InterestingDecls; 790 791 /// \brief The set of redeclarable declarations that have been deserialized 792 /// since the last time the declaration chains were linked. 793 llvm::SmallPtrSet<Decl *, 16> RedeclsDeserialized; 794 795 /// \brief The list of redeclaration chains that still need to be 796 /// reconstructed. 797 /// 798 /// Each element is the global declaration ID of the first declaration in 799 /// the chain. Elements in this vector should be unique; use 800 /// PendingDeclChainsKnown to ensure uniqueness. 801 llvm::SmallVector<serialization::DeclID, 16> PendingDeclChains; 802 803 /// \brief Keeps track of the elements added to PendingDeclChains. 804 llvm::SmallSet<serialization::DeclID, 16> PendingDeclChainsKnown; 805 806 /// \brief The set of Objective-C categories that have been deserialized 807 /// since the last time the declaration chains were linked. 808 llvm::SmallPtrSet<ObjCCategoryDecl *, 16> CategoriesDeserialized; 809 810 /// \brief The set of Objective-C class definitions that have already been 811 /// loaded, for which we will need to check for categories whenever a new 812 /// module is loaded. 813 llvm::SmallVector<ObjCInterfaceDecl *, 16> ObjCClassesLoaded; 814 815 typedef llvm::DenseMap<Decl *, llvm::SmallVector<serialization::DeclID, 2> > 816 MergedDeclsMap; 817 818 /// \brief A mapping from canonical declarations to the set of additional 819 /// (global, previously-canonical) declaration IDs that have been merged with 820 /// that canonical declaration. 821 MergedDeclsMap MergedDecls; 822 823 typedef llvm::DenseMap<serialization::GlobalDeclID, 824 llvm::SmallVector<serialization::DeclID, 2> > 825 StoredMergedDeclsMap; 826 827 /// \brief A mapping from canonical declaration IDs to the set of additional 828 /// declaration IDs that have been merged with that canonical declaration. 829 /// 830 /// This is the deserialized representation of the entries in MergedDecls. 831 /// When we query entries in MergedDecls, they will be augmented with entries 832 /// from StoredMergedDecls. 833 StoredMergedDeclsMap StoredMergedDecls; 834 835 /// \brief Combine the stored merged declarations for the given canonical 836 /// declaration into the set of merged declarations. 837 /// 838 /// \returns An iterator into MergedDecls that corresponds to the position of 839 /// the given canonical declaration. 840 MergedDeclsMap::iterator 841 combineStoredMergedDecls(Decl *Canon, serialization::GlobalDeclID CanonID); 842 843 /// \brief Ready to load the previous declaration of the given Decl. 844 void loadAndAttachPreviousDecl(Decl *D, serialization::DeclID ID); 845 846 /// \brief When reading a Stmt tree, Stmt operands are placed in this stack. 847 SmallVector<Stmt *, 16> StmtStack; 848 849 /// \brief What kind of records we are reading. 850 enum ReadingKind { 851 Read_Decl, Read_Type, Read_Stmt 852 }; 853 854 /// \brief What kind of records we are reading. 855 ReadingKind ReadingKind; 856 857 /// \brief RAII object to change the reading kind. 858 class ReadingKindTracker { 859 ASTReader &Reader; 860 enum ReadingKind PrevKind; 861 862 ReadingKindTracker(const ReadingKindTracker &) LLVM_DELETED_FUNCTION; 863 void operator=(const ReadingKindTracker &) LLVM_DELETED_FUNCTION; 864 865 public: 866 ReadingKindTracker(enum ReadingKind newKind, ASTReader &reader) 867 : Reader(reader), PrevKind(Reader.ReadingKind) { 868 Reader.ReadingKind = newKind; 869 } 870 871 ~ReadingKindTracker() { Reader.ReadingKind = PrevKind; } 872 }; 873 874 /// \brief Suggested contents of the predefines buffer, after this 875 /// PCH file has been processed. 876 /// 877 /// In most cases, this string will be empty, because the predefines 878 /// buffer computed to build the PCH file will be identical to the 879 /// predefines buffer computed from the command line. However, when 880 /// there are differences that the PCH reader can work around, this 881 /// predefines buffer may contain additional definitions. 882 std::string SuggestedPredefines; 883 884 /// \brief Reads a statement from the specified cursor. 885 Stmt *ReadStmtFromStream(ModuleFile &F); 886 887 typedef llvm::PointerIntPair<const FileEntry *, 1, bool> InputFile; 888 889 /// \brief Retrieve the file entry and 'overridden' bit for an input 890 /// file in the given module file. 891 InputFile getInputFile(ModuleFile &F, unsigned ID, bool Complain = true); 892 893 /// \brief Get a FileEntry out of stored-in-PCH filename, making sure we take 894 /// into account all the necessary relocations. 895 const FileEntry *getFileEntry(StringRef filename); 896 897 void MaybeAddSystemRootToFilename(ModuleFile &M, std::string &Filename); 898 899 struct ImportedModule { 900 ModuleFile *Mod; 901 ModuleFile *ImportedBy; 902 SourceLocation ImportLoc; 903 904 ImportedModule(ModuleFile *Mod, 905 ModuleFile *ImportedBy, 906 SourceLocation ImportLoc) 907 : Mod(Mod), ImportedBy(ImportedBy), ImportLoc(ImportLoc) { } 908 }; 909 910 ASTReadResult ReadASTCore(StringRef FileName, ModuleKind Type, 911 SourceLocation ImportLoc, ModuleFile *ImportedBy, 912 llvm::SmallVectorImpl<ImportedModule> &Loaded, 913 unsigned ClientLoadCapabilities); 914 ASTReadResult ReadControlBlock(ModuleFile &F, 915 llvm::SmallVectorImpl<ImportedModule> &Loaded, 916 unsigned ClientLoadCapabilities); 917 bool ReadASTBlock(ModuleFile &F); 918 bool ParseLineTable(ModuleFile &F, SmallVectorImpl<uint64_t> &Record); 919 bool ReadSourceManagerBlock(ModuleFile &F); 920 llvm::BitstreamCursor &SLocCursorForID(int ID); 921 SourceLocation getImportLocation(ModuleFile *F); 922 bool ReadSubmoduleBlock(ModuleFile &F); 923 static bool ParseLanguageOptions(const RecordData &Record, bool Complain, 924 ASTReaderListener &Listener); 925 static bool ParseTargetOptions(const RecordData &Record, bool Complain, 926 ASTReaderListener &Listener); 927 static bool ParseDiagnosticOptions(const RecordData &Record, bool Complain, 928 ASTReaderListener &Listener); 929 static bool ParseFileSystemOptions(const RecordData &Record, bool Complain, 930 ASTReaderListener &Listener); 931 static bool ParseHeaderSearchOptions(const RecordData &Record, bool Complain, 932 ASTReaderListener &Listener); 933 static bool ParsePreprocessorOptions(const RecordData &Record, bool Complain, 934 ASTReaderListener &Listener, 935 std::string &SuggestedPredefines); 936 937 struct RecordLocation { 938 RecordLocation(ModuleFile *M, uint64_t O) 939 : F(M), Offset(O) {} 940 ModuleFile *F; 941 uint64_t Offset; 942 }; 943 944 QualType readTypeRecord(unsigned Index); 945 RecordLocation TypeCursorForIndex(unsigned Index); 946 void LoadedDecl(unsigned Index, Decl *D); 947 Decl *ReadDeclRecord(serialization::DeclID ID); 948 RecordLocation DeclCursorForID(serialization::DeclID ID, 949 unsigned &RawLocation); 950 void loadDeclUpdateRecords(serialization::DeclID ID, Decl *D); 951 void loadPendingDeclChain(serialization::GlobalDeclID ID); 952 void loadObjCCategories(serialization::GlobalDeclID ID, ObjCInterfaceDecl *D, 953 unsigned PreviousGeneration = 0); 954 955 RecordLocation getLocalBitOffset(uint64_t GlobalOffset); 956 uint64_t getGlobalBitOffset(ModuleFile &M, uint32_t LocalOffset); 957 958 /// \brief Returns the first preprocessed entity ID that ends after BLoc. 959 serialization::PreprocessedEntityID 960 findBeginPreprocessedEntity(SourceLocation BLoc) const; 961 962 /// \brief Returns the first preprocessed entity ID that begins after ELoc. 963 serialization::PreprocessedEntityID 964 findEndPreprocessedEntity(SourceLocation ELoc) const; 965 966 /// \brief Find the next module that contains entities and return the ID 967 /// of the first entry. 968 /// 969 /// \param SLocMapI points at a chunk of a module that contains no 970 /// preprocessed entities or the entities it contains are not the 971 /// ones we are looking for. 972 serialization::PreprocessedEntityID 973 findNextPreprocessedEntity( 974 GlobalSLocOffsetMapType::const_iterator SLocMapI) const; 975 976 /// \brief Returns (ModuleFile, Local index) pair for \p GlobalIndex of a 977 /// preprocessed entity. 978 std::pair<ModuleFile *, unsigned> 979 getModulePreprocessedEntity(unsigned GlobalIndex); 980 981 /// \brief Returns (begin, end) pair for the preprocessed entities of a 982 /// particular module. 983 std::pair<PreprocessingRecord::iterator, PreprocessingRecord::iterator> 984 getModulePreprocessedEntities(ModuleFile &Mod) const; 985 986 class ModuleDeclIterator { 987 ASTReader *Reader; 988 ModuleFile *Mod; 989 const serialization::LocalDeclID *Pos; 990 991 public: 992 typedef const Decl *value_type; 993 typedef value_type& reference; 994 typedef value_type* pointer; 995 996 ModuleDeclIterator() : Reader(0), Mod(0), Pos(0) { } 997 998 ModuleDeclIterator(ASTReader *Reader, ModuleFile *Mod, 999 const serialization::LocalDeclID *Pos) 1000 : Reader(Reader), Mod(Mod), Pos(Pos) { } 1001 1002 value_type operator*() const { 1003 return Reader->GetDecl(Reader->getGlobalDeclID(*Mod, *Pos)); 1004 } 1005 1006 ModuleDeclIterator &operator++() { 1007 ++Pos; 1008 return *this; 1009 } 1010 1011 ModuleDeclIterator operator++(int) { 1012 ModuleDeclIterator Prev(*this); 1013 ++Pos; 1014 return Prev; 1015 } 1016 1017 ModuleDeclIterator &operator--() { 1018 --Pos; 1019 return *this; 1020 } 1021 1022 ModuleDeclIterator operator--(int) { 1023 ModuleDeclIterator Prev(*this); 1024 --Pos; 1025 return Prev; 1026 } 1027 1028 friend bool operator==(const ModuleDeclIterator &LHS, 1029 const ModuleDeclIterator &RHS) { 1030 assert(LHS.Reader == RHS.Reader && LHS.Mod == RHS.Mod); 1031 return LHS.Pos == RHS.Pos; 1032 } 1033 1034 friend bool operator!=(const ModuleDeclIterator &LHS, 1035 const ModuleDeclIterator &RHS) { 1036 assert(LHS.Reader == RHS.Reader && LHS.Mod == RHS.Mod); 1037 return LHS.Pos != RHS.Pos; 1038 } 1039 }; 1040 1041 std::pair<ModuleDeclIterator, ModuleDeclIterator> 1042 getModuleFileLevelDecls(ModuleFile &Mod); 1043 1044 void PassInterestingDeclsToConsumer(); 1045 void PassInterestingDeclToConsumer(Decl *D); 1046 1047 void finishPendingActions(); 1048 1049 /// \brief Produce an error diagnostic and return true. 1050 /// 1051 /// This routine should only be used for fatal errors that have to 1052 /// do with non-routine failures (e.g., corrupted AST file). 1053 void Error(StringRef Msg); 1054 void Error(unsigned DiagID, StringRef Arg1 = StringRef(), 1055 StringRef Arg2 = StringRef()); 1056 1057 ASTReader(const ASTReader &) LLVM_DELETED_FUNCTION; 1058 void operator=(const ASTReader &) LLVM_DELETED_FUNCTION; 1059public: 1060 /// \brief Load the AST file and validate its contents against the given 1061 /// Preprocessor. 1062 /// 1063 /// \param PP the preprocessor associated with the context in which this 1064 /// precompiled header will be loaded. 1065 /// 1066 /// \param Context the AST context that this precompiled header will be 1067 /// loaded into. 1068 /// 1069 /// \param isysroot If non-NULL, the system include path specified by the 1070 /// user. This is only used with relocatable PCH files. If non-NULL, 1071 /// a relocatable PCH file will use the default path "/". 1072 /// 1073 /// \param DisableValidation If true, the AST reader will suppress most 1074 /// of its regular consistency checking, allowing the use of precompiled 1075 /// headers that cannot be determined to be compatible. 1076 /// 1077 /// \param AllowASTWithCompilerErrors If true, the AST reader will accept an 1078 /// AST file the was created out of an AST with compiler errors, 1079 /// otherwise it will reject it. 1080 ASTReader(Preprocessor &PP, ASTContext &Context, StringRef isysroot = "", 1081 bool DisableValidation = false, 1082 bool AllowASTWithCompilerErrors = false); 1083 1084 ~ASTReader(); 1085 1086 SourceManager &getSourceManager() const { return SourceMgr; } 1087 1088 /// \brief Flags that indicate what kind of AST loading failures the client 1089 /// of the AST reader can directly handle. 1090 /// 1091 /// When a client states that it can handle a particular kind of failure, 1092 /// the AST reader will not emit errors when producing that kind of failure. 1093 enum LoadFailureCapabilities { 1094 /// \brief The client can't handle any AST loading failures. 1095 ARR_None = 0, 1096 /// \brief The client can handle an AST file that cannot load because it 1097 /// is out-of-date relative to its input files. 1098 ARR_OutOfDate = 0x1, 1099 /// \brief The client can handle an AST file that cannot load because it 1100 /// was built with a different version of Clang. 1101 ARR_VersionMismatch = 0x2, 1102 /// \brief The client can handle an AST file that cannot load because it's 1103 /// compiled configuration doesn't match that of the context it was 1104 /// loaded into. 1105 ARR_ConfigurationMismatch = 0x4 1106 }; 1107 1108 /// \brief Load the AST file designated by the given file name. 1109 /// 1110 /// \param FileName The name of the AST file to load. 1111 /// 1112 /// \param Type The kind of AST being loaded, e.g., PCH, module, main file, 1113 /// or preamble. 1114 /// 1115 /// \param ImportLoc the location where the module file will be considered as 1116 /// imported from. For non-module AST types it should be invalid. 1117 /// 1118 /// \param ClientLoadCapabilities The set of client load-failure 1119 /// capabilities, represented as a bitset of the enumerators of 1120 /// LoadFailureCapabilities. 1121 ASTReadResult ReadAST(const std::string &FileName, ModuleKind Type, 1122 SourceLocation ImportLoc, 1123 unsigned ClientLoadCapabilities); 1124 1125 /// \brief Make the entities in the given module and any of its (non-explicit) 1126 /// submodules visible to name lookup. 1127 /// 1128 /// \param Mod The module whose names should be made visible. 1129 /// 1130 /// \param NameVisibility The level of visibility to give the names in the 1131 /// module. Visibility can only be increased over time. 1132 void makeModuleVisible(Module *Mod, 1133 Module::NameVisibilityKind NameVisibility); 1134 1135 /// \brief Make the names within this set of hidden names visible. 1136 void makeNamesVisible(const HiddenNames &Names); 1137 1138 /// \brief Set the AST callbacks listener. 1139 void setListener(ASTReaderListener *listener) { 1140 Listener.reset(listener); 1141 } 1142 1143 /// \brief Set the AST deserialization listener. 1144 void setDeserializationListener(ASTDeserializationListener *Listener); 1145 1146 /// \brief Initializes the ASTContext 1147 void InitializeContext(); 1148 1149 /// \brief Add in-memory (virtual file) buffer. 1150 void addInMemoryBuffer(StringRef &FileName, llvm::MemoryBuffer *Buffer) { 1151 ModuleMgr.addInMemoryBuffer(FileName, Buffer); 1152 } 1153 1154 /// \brief Finalizes the AST reader's state before writing an AST file to 1155 /// disk. 1156 /// 1157 /// This operation may undo temporary state in the AST that should not be 1158 /// emitted. 1159 void finalizeForWriting(); 1160 1161 /// \brief Retrieve the module manager. 1162 ModuleManager &getModuleManager() { return ModuleMgr; } 1163 1164 /// \brief Retrieve the preprocessor. 1165 Preprocessor &getPreprocessor() const { return PP; } 1166 1167 /// \brief Retrieve the name of the original source file name for the primary 1168 /// module file. 1169 StringRef getOriginalSourceFile() { 1170 return ModuleMgr.getPrimaryModule().OriginalSourceFileName; 1171 } 1172 1173 /// \brief Retrieve the name of the original source file name directly from 1174 /// the AST file, without actually loading the AST file. 1175 static std::string getOriginalSourceFile(const std::string &ASTFileName, 1176 FileManager &FileMgr, 1177 DiagnosticsEngine &Diags); 1178 1179 /// \brief Read the control block for the named AST file. 1180 /// 1181 /// \returns true if an error occurred, false otherwise. 1182 static bool readASTFileControlBlock(StringRef Filename, 1183 FileManager &FileMgr, 1184 ASTReaderListener &Listener); 1185 1186 /// \brief Determine whether the given AST file is acceptable to load into a 1187 /// translation unit with the given language and target options. 1188 static bool isAcceptableASTFile(StringRef Filename, 1189 FileManager &FileMgr, 1190 const LangOptions &LangOpts, 1191 const TargetOptions &TargetOpts, 1192 const PreprocessorOptions &PPOpts); 1193 1194 /// \brief Returns the suggested contents of the predefines buffer, 1195 /// which contains a (typically-empty) subset of the predefines 1196 /// build prior to including the precompiled header. 1197 const std::string &getSuggestedPredefines() { return SuggestedPredefines; } 1198 1199 /// \brief Read a preallocated preprocessed entity from the external source. 1200 /// 1201 /// \returns null if an error occurred that prevented the preprocessed 1202 /// entity from being loaded. 1203 virtual PreprocessedEntity *ReadPreprocessedEntity(unsigned Index); 1204 1205 /// \brief Returns a pair of [Begin, End) indices of preallocated 1206 /// preprocessed entities that \p Range encompasses. 1207 virtual std::pair<unsigned, unsigned> 1208 findPreprocessedEntitiesInRange(SourceRange Range); 1209 1210 /// \brief Optionally returns true or false if the preallocated preprocessed 1211 /// entity with index \p Index came from file \p FID. 1212 virtual llvm::Optional<bool> isPreprocessedEntityInFileID(unsigned Index, 1213 FileID FID); 1214 1215 /// \brief Read the header file information for the given file entry. 1216 virtual HeaderFileInfo GetHeaderFileInfo(const FileEntry *FE); 1217 1218 void ReadPragmaDiagnosticMappings(DiagnosticsEngine &Diag); 1219 1220 /// \brief Returns the number of source locations found in the chain. 1221 unsigned getTotalNumSLocs() const { 1222 return TotalNumSLocEntries; 1223 } 1224 1225 /// \brief Returns the number of identifiers found in the chain. 1226 unsigned getTotalNumIdentifiers() const { 1227 return static_cast<unsigned>(IdentifiersLoaded.size()); 1228 } 1229 1230 /// \brief Returns the number of macros found in the chain. 1231 unsigned getTotalNumMacros() const { 1232 return static_cast<unsigned>(MacrosLoaded.size()); 1233 } 1234 1235 /// \brief Returns the number of types found in the chain. 1236 unsigned getTotalNumTypes() const { 1237 return static_cast<unsigned>(TypesLoaded.size()); 1238 } 1239 1240 /// \brief Returns the number of declarations found in the chain. 1241 unsigned getTotalNumDecls() const { 1242 return static_cast<unsigned>(DeclsLoaded.size()); 1243 } 1244 1245 /// \brief Returns the number of submodules known. 1246 unsigned getTotalNumSubmodules() const { 1247 return static_cast<unsigned>(SubmodulesLoaded.size()); 1248 } 1249 1250 /// \brief Returns the number of selectors found in the chain. 1251 unsigned getTotalNumSelectors() const { 1252 return static_cast<unsigned>(SelectorsLoaded.size()); 1253 } 1254 1255 /// \brief Returns the number of preprocessed entities known to the AST 1256 /// reader. 1257 unsigned getTotalNumPreprocessedEntities() const { 1258 unsigned Result = 0; 1259 for (ModuleConstIterator I = ModuleMgr.begin(), 1260 E = ModuleMgr.end(); I != E; ++I) { 1261 Result += (*I)->NumPreprocessedEntities; 1262 } 1263 1264 return Result; 1265 } 1266 1267 /// \brief Returns the number of C++ base specifiers found in the chain. 1268 unsigned getTotalNumCXXBaseSpecifiers() const { 1269 return NumCXXBaseSpecifiersLoaded; 1270 } 1271 1272 /// \brief Reads a TemplateArgumentLocInfo appropriate for the 1273 /// given TemplateArgument kind. 1274 TemplateArgumentLocInfo 1275 GetTemplateArgumentLocInfo(ModuleFile &F, TemplateArgument::ArgKind Kind, 1276 const RecordData &Record, unsigned &Idx); 1277 1278 /// \brief Reads a TemplateArgumentLoc. 1279 TemplateArgumentLoc 1280 ReadTemplateArgumentLoc(ModuleFile &F, 1281 const RecordData &Record, unsigned &Idx); 1282 1283 /// \brief Reads a declarator info from the given record. 1284 TypeSourceInfo *GetTypeSourceInfo(ModuleFile &F, 1285 const RecordData &Record, unsigned &Idx); 1286 1287 /// \brief Resolve a type ID into a type, potentially building a new 1288 /// type. 1289 QualType GetType(serialization::TypeID ID); 1290 1291 /// \brief Resolve a local type ID within a given AST file into a type. 1292 QualType getLocalType(ModuleFile &F, unsigned LocalID); 1293 1294 /// \brief Map a local type ID within a given AST file into a global type ID. 1295 serialization::TypeID getGlobalTypeID(ModuleFile &F, unsigned LocalID) const; 1296 1297 /// \brief Read a type from the current position in the given record, which 1298 /// was read from the given AST file. 1299 QualType readType(ModuleFile &F, const RecordData &Record, unsigned &Idx) { 1300 if (Idx >= Record.size()) 1301 return QualType(); 1302 1303 return getLocalType(F, Record[Idx++]); 1304 } 1305 1306 /// \brief Map from a local declaration ID within a given module to a 1307 /// global declaration ID. 1308 serialization::DeclID getGlobalDeclID(ModuleFile &F, 1309 serialization::LocalDeclID LocalID) const; 1310 1311 /// \brief Returns true if global DeclID \p ID originated from module \p M. 1312 bool isDeclIDFromModule(serialization::GlobalDeclID ID, ModuleFile &M) const; 1313 1314 /// \brief Retrieve the module file that owns the given declaration, or NULL 1315 /// if the declaration is not from a module file. 1316 ModuleFile *getOwningModuleFile(Decl *D); 1317 1318 /// \brief Returns the source location for the decl \p ID. 1319 SourceLocation getSourceLocationForDeclID(serialization::GlobalDeclID ID); 1320 1321 /// \brief Resolve a declaration ID into a declaration, potentially 1322 /// building a new declaration. 1323 Decl *GetDecl(serialization::DeclID ID); 1324 virtual Decl *GetExternalDecl(uint32_t ID); 1325 1326 /// \brief Reads a declaration with the given local ID in the given module. 1327 Decl *GetLocalDecl(ModuleFile &F, uint32_t LocalID) { 1328 return GetDecl(getGlobalDeclID(F, LocalID)); 1329 } 1330 1331 /// \brief Reads a declaration with the given local ID in the given module. 1332 /// 1333 /// \returns The requested declaration, casted to the given return type. 1334 template<typename T> 1335 T *GetLocalDeclAs(ModuleFile &F, uint32_t LocalID) { 1336 return cast_or_null<T>(GetLocalDecl(F, LocalID)); 1337 } 1338 1339 /// \brief Map a global declaration ID into the declaration ID used to 1340 /// refer to this declaration within the given module fule. 1341 /// 1342 /// \returns the global ID of the given declaration as known in the given 1343 /// module file. 1344 serialization::DeclID 1345 mapGlobalIDToModuleFileGlobalID(ModuleFile &M, 1346 serialization::DeclID GlobalID); 1347 1348 /// \brief Reads a declaration ID from the given position in a record in the 1349 /// given module. 1350 /// 1351 /// \returns The declaration ID read from the record, adjusted to a global ID. 1352 serialization::DeclID ReadDeclID(ModuleFile &F, const RecordData &Record, 1353 unsigned &Idx); 1354 1355 /// \brief Reads a declaration from the given position in a record in the 1356 /// given module. 1357 Decl *ReadDecl(ModuleFile &F, const RecordData &R, unsigned &I) { 1358 return GetDecl(ReadDeclID(F, R, I)); 1359 } 1360 1361 /// \brief Reads a declaration from the given position in a record in the 1362 /// given module. 1363 /// 1364 /// \returns The declaration read from this location, casted to the given 1365 /// result type. 1366 template<typename T> 1367 T *ReadDeclAs(ModuleFile &F, const RecordData &R, unsigned &I) { 1368 return cast_or_null<T>(GetDecl(ReadDeclID(F, R, I))); 1369 } 1370 1371 /// \brief Read a CXXBaseSpecifiers ID form the given record and 1372 /// return its global bit offset. 1373 uint64_t readCXXBaseSpecifiers(ModuleFile &M, const RecordData &Record, 1374 unsigned &Idx); 1375 1376 virtual CXXBaseSpecifier *GetExternalCXXBaseSpecifiers(uint64_t Offset); 1377 1378 /// \brief Resolve the offset of a statement into a statement. 1379 /// 1380 /// This operation will read a new statement from the external 1381 /// source each time it is called, and is meant to be used via a 1382 /// LazyOffsetPtr (which is used by Decls for the body of functions, etc). 1383 virtual Stmt *GetExternalDeclStmt(uint64_t Offset); 1384 1385 /// ReadBlockAbbrevs - Enter a subblock of the specified BlockID with the 1386 /// specified cursor. Read the abbreviations that are at the top of the block 1387 /// and then leave the cursor pointing into the block. 1388 bool ReadBlockAbbrevs(llvm::BitstreamCursor &Cursor, unsigned BlockID); 1389 1390 /// \brief Finds all the visible declarations with a given name. 1391 /// The current implementation of this method just loads the entire 1392 /// lookup table as unmaterialized references. 1393 virtual DeclContext::lookup_result 1394 FindExternalVisibleDeclsByName(const DeclContext *DC, 1395 DeclarationName Name); 1396 1397 /// \brief Read all of the declarations lexically stored in a 1398 /// declaration context. 1399 /// 1400 /// \param DC The declaration context whose declarations will be 1401 /// read. 1402 /// 1403 /// \param Decls Vector that will contain the declarations loaded 1404 /// from the external source. The caller is responsible for merging 1405 /// these declarations with any declarations already stored in the 1406 /// declaration context. 1407 /// 1408 /// \returns true if there was an error while reading the 1409 /// declarations for this declaration context. 1410 virtual ExternalLoadResult FindExternalLexicalDecls(const DeclContext *DC, 1411 bool (*isKindWeWant)(Decl::Kind), 1412 SmallVectorImpl<Decl*> &Decls); 1413 1414 /// \brief Get the decls that are contained in a file in the Offset/Length 1415 /// range. \p Length can be 0 to indicate a point at \p Offset instead of 1416 /// a range. 1417 virtual void FindFileRegionDecls(FileID File, unsigned Offset,unsigned Length, 1418 SmallVectorImpl<Decl *> &Decls); 1419 1420 /// \brief Notify ASTReader that we started deserialization of 1421 /// a decl or type so until FinishedDeserializing is called there may be 1422 /// decls that are initializing. Must be paired with FinishedDeserializing. 1423 virtual void StartedDeserializing() { ++NumCurrentElementsDeserializing; } 1424 1425 /// \brief Notify ASTReader that we finished the deserialization of 1426 /// a decl or type. Must be paired with StartedDeserializing. 1427 virtual void FinishedDeserializing(); 1428 1429 /// \brief Function that will be invoked when we begin parsing a new 1430 /// translation unit involving this external AST source. 1431 /// 1432 /// This function will provide all of the external definitions to 1433 /// the ASTConsumer. 1434 virtual void StartTranslationUnit(ASTConsumer *Consumer); 1435 1436 /// \brief Print some statistics about AST usage. 1437 virtual void PrintStats(); 1438 1439 /// \brief Dump information about the AST reader to standard error. 1440 void dump(); 1441 1442 /// Return the amount of memory used by memory buffers, breaking down 1443 /// by heap-backed versus mmap'ed memory. 1444 virtual void getMemoryBufferSizes(MemoryBufferSizes &sizes) const; 1445 1446 /// \brief Initialize the semantic source with the Sema instance 1447 /// being used to perform semantic analysis on the abstract syntax 1448 /// tree. 1449 virtual void InitializeSema(Sema &S); 1450 1451 /// \brief Inform the semantic consumer that Sema is no longer available. 1452 virtual void ForgetSema() { SemaObj = 0; } 1453 1454 /// \brief Retrieve the IdentifierInfo for the named identifier. 1455 /// 1456 /// This routine builds a new IdentifierInfo for the given identifier. If any 1457 /// declarations with this name are visible from translation unit scope, their 1458 /// declarations will be deserialized and introduced into the declaration 1459 /// chain of the identifier. 1460 virtual IdentifierInfo *get(const char *NameStart, const char *NameEnd); 1461 IdentifierInfo *get(StringRef Name) { 1462 return get(Name.begin(), Name.end()); 1463 } 1464 1465 /// \brief Retrieve an iterator into the set of all identifiers 1466 /// in all loaded AST files. 1467 virtual IdentifierIterator *getIdentifiers() const; 1468 1469 /// \brief Load the contents of the global method pool for a given 1470 /// selector. 1471 virtual void ReadMethodPool(Selector Sel); 1472 1473 /// \brief Load the set of namespaces that are known to the external source, 1474 /// which will be used during typo correction. 1475 virtual void ReadKnownNamespaces( 1476 SmallVectorImpl<NamespaceDecl *> &Namespaces); 1477 1478 virtual void ReadTentativeDefinitions( 1479 SmallVectorImpl<VarDecl *> &TentativeDefs); 1480 1481 virtual void ReadUnusedFileScopedDecls( 1482 SmallVectorImpl<const DeclaratorDecl *> &Decls); 1483 1484 virtual void ReadDelegatingConstructors( 1485 SmallVectorImpl<CXXConstructorDecl *> &Decls); 1486 1487 virtual void ReadExtVectorDecls(SmallVectorImpl<TypedefNameDecl *> &Decls); 1488 1489 virtual void ReadDynamicClasses(SmallVectorImpl<CXXRecordDecl *> &Decls); 1490 1491 virtual void ReadLocallyScopedExternCDecls( 1492 SmallVectorImpl<NamedDecl *> &Decls); 1493 1494 virtual void ReadReferencedSelectors( 1495 SmallVectorImpl<std::pair<Selector, SourceLocation> > &Sels); 1496 1497 virtual void ReadWeakUndeclaredIdentifiers( 1498 SmallVectorImpl<std::pair<IdentifierInfo *, WeakInfo> > &WI); 1499 1500 virtual void ReadUsedVTables(SmallVectorImpl<ExternalVTableUse> &VTables); 1501 1502 virtual void ReadPendingInstantiations( 1503 SmallVectorImpl<std::pair<ValueDecl *, 1504 SourceLocation> > &Pending); 1505 1506 /// \brief Load a selector from disk, registering its ID if it exists. 1507 void LoadSelector(Selector Sel); 1508 1509 void SetIdentifierInfo(unsigned ID, IdentifierInfo *II); 1510 void SetGloballyVisibleDecls(IdentifierInfo *II, 1511 const SmallVectorImpl<uint32_t> &DeclIDs, 1512 bool Nonrecursive = false); 1513 1514 /// \brief Report a diagnostic. 1515 DiagnosticBuilder Diag(unsigned DiagID); 1516 1517 /// \brief Report a diagnostic. 1518 DiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID); 1519 1520 IdentifierInfo *DecodeIdentifierInfo(serialization::IdentifierID ID); 1521 1522 IdentifierInfo *GetIdentifierInfo(ModuleFile &M, const RecordData &Record, 1523 unsigned &Idx) { 1524 return DecodeIdentifierInfo(getGlobalIdentifierID(M, Record[Idx++])); 1525 } 1526 1527 virtual IdentifierInfo *GetIdentifier(serialization::IdentifierID ID) { 1528 // Note that we are loading an identifier. 1529 Deserializing AnIdentifier(this); 1530 1531 return DecodeIdentifierInfo(ID); 1532 } 1533 1534 IdentifierInfo *getLocalIdentifier(ModuleFile &M, unsigned LocalID); 1535 1536 serialization::IdentifierID getGlobalIdentifierID(ModuleFile &M, 1537 unsigned LocalID); 1538 1539 /// \brief Retrieve the macro with the given ID. 1540 MacroInfo *getMacro(serialization::MacroID ID, MacroInfo *Hint = 0); 1541 1542 /// \brief Retrieve the global macro ID corresponding to the given local 1543 /// ID within the given module file. 1544 serialization::MacroID getGlobalMacroID(ModuleFile &M, unsigned LocalID); 1545 1546 /// \brief Read the source location entry with index ID. 1547 virtual bool ReadSLocEntry(int ID); 1548 1549 /// \brief Retrieve the module import location and module name for the 1550 /// given source manager entry ID. 1551 virtual std::pair<SourceLocation, StringRef> getModuleImportLoc(int ID); 1552 1553 /// \brief Retrieve the global submodule ID given a module and its local ID 1554 /// number. 1555 serialization::SubmoduleID 1556 getGlobalSubmoduleID(ModuleFile &M, unsigned LocalID); 1557 1558 /// \brief Retrieve the submodule that corresponds to a global submodule ID. 1559 /// 1560 Module *getSubmodule(serialization::SubmoduleID GlobalID); 1561 1562 /// \brief Retrieve the module that corresponds to the given module ID. 1563 /// 1564 /// Note: overrides method in ExternalASTSource 1565 virtual Module *getModule(unsigned ID); 1566 1567 /// \brief Retrieve a selector from the given module with its local ID 1568 /// number. 1569 Selector getLocalSelector(ModuleFile &M, unsigned LocalID); 1570 1571 Selector DecodeSelector(serialization::SelectorID Idx); 1572 1573 virtual Selector GetExternalSelector(serialization::SelectorID ID); 1574 uint32_t GetNumExternalSelectors(); 1575 1576 Selector ReadSelector(ModuleFile &M, const RecordData &Record, unsigned &Idx) { 1577 return getLocalSelector(M, Record[Idx++]); 1578 } 1579 1580 /// \brief Retrieve the global selector ID that corresponds to this 1581 /// the local selector ID in a given module. 1582 serialization::SelectorID getGlobalSelectorID(ModuleFile &F, 1583 unsigned LocalID) const; 1584 1585 /// \brief Read a declaration name. 1586 DeclarationName ReadDeclarationName(ModuleFile &F, 1587 const RecordData &Record, unsigned &Idx); 1588 void ReadDeclarationNameLoc(ModuleFile &F, 1589 DeclarationNameLoc &DNLoc, DeclarationName Name, 1590 const RecordData &Record, unsigned &Idx); 1591 void ReadDeclarationNameInfo(ModuleFile &F, DeclarationNameInfo &NameInfo, 1592 const RecordData &Record, unsigned &Idx); 1593 1594 void ReadQualifierInfo(ModuleFile &F, QualifierInfo &Info, 1595 const RecordData &Record, unsigned &Idx); 1596 1597 NestedNameSpecifier *ReadNestedNameSpecifier(ModuleFile &F, 1598 const RecordData &Record, 1599 unsigned &Idx); 1600 1601 NestedNameSpecifierLoc ReadNestedNameSpecifierLoc(ModuleFile &F, 1602 const RecordData &Record, 1603 unsigned &Idx); 1604 1605 /// \brief Read a template name. 1606 TemplateName ReadTemplateName(ModuleFile &F, const RecordData &Record, 1607 unsigned &Idx); 1608 1609 /// \brief Read a template argument. 1610 TemplateArgument ReadTemplateArgument(ModuleFile &F, 1611 const RecordData &Record,unsigned &Idx); 1612 1613 /// \brief Read a template parameter list. 1614 TemplateParameterList *ReadTemplateParameterList(ModuleFile &F, 1615 const RecordData &Record, 1616 unsigned &Idx); 1617 1618 /// \brief Read a template argument array. 1619 void 1620 ReadTemplateArgumentList(SmallVector<TemplateArgument, 8> &TemplArgs, 1621 ModuleFile &F, const RecordData &Record, 1622 unsigned &Idx); 1623 1624 /// \brief Read a UnresolvedSet structure. 1625 void ReadUnresolvedSet(ModuleFile &F, ASTUnresolvedSet &Set, 1626 const RecordData &Record, unsigned &Idx); 1627 1628 /// \brief Read a C++ base specifier. 1629 CXXBaseSpecifier ReadCXXBaseSpecifier(ModuleFile &F, 1630 const RecordData &Record,unsigned &Idx); 1631 1632 /// \brief Read a CXXCtorInitializer array. 1633 std::pair<CXXCtorInitializer **, unsigned> 1634 ReadCXXCtorInitializers(ModuleFile &F, const RecordData &Record, 1635 unsigned &Idx); 1636 1637 /// \brief Read a source location from raw form. 1638 SourceLocation ReadSourceLocation(ModuleFile &ModuleFile, unsigned Raw) const { 1639 SourceLocation Loc = SourceLocation::getFromRawEncoding(Raw); 1640 assert(ModuleFile.SLocRemap.find(Loc.getOffset()) != ModuleFile.SLocRemap.end() && 1641 "Cannot find offset to remap."); 1642 int Remap = ModuleFile.SLocRemap.find(Loc.getOffset())->second; 1643 return Loc.getLocWithOffset(Remap); 1644 } 1645 1646 /// \brief Read a source location. 1647 SourceLocation ReadSourceLocation(ModuleFile &ModuleFile, 1648 const RecordData &Record, unsigned& Idx) { 1649 return ReadSourceLocation(ModuleFile, Record[Idx++]); 1650 } 1651 1652 /// \brief Read a source range. 1653 SourceRange ReadSourceRange(ModuleFile &F, 1654 const RecordData &Record, unsigned& Idx); 1655 1656 /// \brief Read an integral value 1657 llvm::APInt ReadAPInt(const RecordData &Record, unsigned &Idx); 1658 1659 /// \brief Read a signed integral value 1660 llvm::APSInt ReadAPSInt(const RecordData &Record, unsigned &Idx); 1661 1662 /// \brief Read a floating-point value 1663 llvm::APFloat ReadAPFloat(const RecordData &Record, unsigned &Idx); 1664 1665 // \brief Read a string 1666 static std::string ReadString(const RecordData &Record, unsigned &Idx); 1667 1668 /// \brief Read a version tuple. 1669 static VersionTuple ReadVersionTuple(const RecordData &Record, unsigned &Idx); 1670 1671 CXXTemporary *ReadCXXTemporary(ModuleFile &F, const RecordData &Record, 1672 unsigned &Idx); 1673 1674 /// \brief Reads attributes from the current stream position. 1675 void ReadAttributes(ModuleFile &F, AttrVec &Attrs, 1676 const RecordData &Record, unsigned &Idx); 1677 1678 /// \brief Reads a statement. 1679 Stmt *ReadStmt(ModuleFile &F); 1680 1681 /// \brief Reads an expression. 1682 Expr *ReadExpr(ModuleFile &F); 1683 1684 /// \brief Reads a sub-statement operand during statement reading. 1685 Stmt *ReadSubStmt() { 1686 assert(ReadingKind == Read_Stmt && 1687 "Should be called only during statement reading!"); 1688 // Subexpressions are stored from last to first, so the next Stmt we need 1689 // is at the back of the stack. 1690 assert(!StmtStack.empty() && "Read too many sub statements!"); 1691 return StmtStack.pop_back_val(); 1692 } 1693 1694 /// \brief Reads a sub-expression operand during statement reading. 1695 Expr *ReadSubExpr(); 1696 1697 /// \brief Reads the macro record located at the given offset. 1698 void ReadMacroRecord(ModuleFile &F, uint64_t Offset, MacroInfo *Hint = 0); 1699 1700 /// \brief Determine the global preprocessed entity ID that corresponds to 1701 /// the given local ID within the given module. 1702 serialization::PreprocessedEntityID 1703 getGlobalPreprocessedEntityID(ModuleFile &M, unsigned LocalID) const; 1704 1705 /// \brief Note that the identifier has a macro history. 1706 /// 1707 /// \param II The name of the macro. 1708 /// 1709 /// \param IDs The global macro IDs that are associated with this identifier. 1710 void setIdentifierIsMacro(IdentifierInfo *II, 1711 ArrayRef<serialization::MacroID> IDs); 1712 1713 /// \brief Read the set of macros defined by this external macro source. 1714 virtual void ReadDefinedMacros(); 1715 1716 /// \brief Update an out-of-date identifier. 1717 virtual void updateOutOfDateIdentifier(IdentifierInfo &II); 1718 1719 /// \brief Note that this identifier is up-to-date. 1720 void markIdentifierUpToDate(IdentifierInfo *II); 1721 1722 /// \brief Load all external visible decls in the given DeclContext. 1723 void completeVisibleDeclsMap(const DeclContext *DC); 1724 1725 /// \brief Retrieve the AST context that this AST reader supplements. 1726 ASTContext &getContext() { return Context; } 1727 1728 // \brief Contains declarations that were loaded before we have 1729 // access to a Sema object. 1730 SmallVector<NamedDecl *, 16> PreloadedDecls; 1731 1732 /// \brief Retrieve the semantic analysis object used to analyze the 1733 /// translation unit in which the precompiled header is being 1734 /// imported. 1735 Sema *getSema() { return SemaObj; } 1736 1737 /// \brief Retrieve the identifier table associated with the 1738 /// preprocessor. 1739 IdentifierTable &getIdentifierTable(); 1740 1741 /// \brief Record that the given ID maps to the given switch-case 1742 /// statement. 1743 void RecordSwitchCaseID(SwitchCase *SC, unsigned ID); 1744 1745 /// \brief Retrieve the switch-case statement with the given ID. 1746 SwitchCase *getSwitchCaseWithID(unsigned ID); 1747 1748 void ClearSwitchCaseIDs(); 1749 1750 /// \brief Cursors for comments blocks. 1751 SmallVector<std::pair<llvm::BitstreamCursor, 1752 serialization::ModuleFile *>, 8> CommentsCursors; 1753 1754 /// \brief Loads comments ranges. 1755 void ReadComments(); 1756}; 1757 1758/// \brief Helper class that saves the current stream position and 1759/// then restores it when destroyed. 1760struct SavedStreamPosition { 1761 explicit SavedStreamPosition(llvm::BitstreamCursor &Cursor) 1762 : Cursor(Cursor), Offset(Cursor.GetCurrentBitNo()) { } 1763 1764 ~SavedStreamPosition() { 1765 Cursor.JumpToBit(Offset); 1766 } 1767 1768private: 1769 llvm::BitstreamCursor &Cursor; 1770 uint64_t Offset; 1771}; 1772 1773inline void PCHValidator::Error(const char *Msg) { 1774 Reader.Error(Msg); 1775} 1776 1777} // end namespace clang 1778 1779#endif 1780