ExternalASTSource.cpp 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. //===- ExternalASTSource.cpp - Abstract External AST Interface --*- 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 provides the default implementation of the ExternalASTSource
  11. // interface, which enables construction of AST nodes from some external
  12. // source.
  13. //
  14. //===----------------------------------------------------------------------===//
  15. #include "clang/AST/ExternalASTSource.h"
  16. #include "clang/AST/ASTContext.h"
  17. #include "clang/AST/DeclarationName.h"
  18. #include "llvm/Support/ErrorHandling.h"
  19. using namespace clang;
  20. ExternalASTSource::~ExternalASTSource() { }
  21. llvm::Optional<ExternalASTSource::ASTSourceDescriptor>
  22. ExternalASTSource::getSourceDescriptor(unsigned ID) {
  23. return None;
  24. }
  25. ExternalASTSource::ASTSourceDescriptor
  26. ExternalASTSource::getSourceDescriptor(const Module &M) {
  27. return ASTSourceDescriptor();
  28. }
  29. void ExternalASTSource::FindFileRegionDecls(FileID File, unsigned Offset,
  30. unsigned Length,
  31. SmallVectorImpl<Decl *> &Decls) {}
  32. void ExternalASTSource::CompleteRedeclChain(const Decl *D) {}
  33. void ExternalASTSource::CompleteType(TagDecl *Tag) {}
  34. void ExternalASTSource::CompleteType(ObjCInterfaceDecl *Class) {}
  35. void ExternalASTSource::ReadComments() {}
  36. void ExternalASTSource::StartedDeserializing() {}
  37. void ExternalASTSource::FinishedDeserializing() {}
  38. void ExternalASTSource::StartTranslationUnit(ASTConsumer *Consumer) {}
  39. void ExternalASTSource::PrintStats() { }
  40. bool ExternalASTSource::layoutRecordType(
  41. const RecordDecl *Record, uint64_t &Size, uint64_t &Alignment,
  42. llvm::DenseMap<const FieldDecl *, uint64_t> &FieldOffsets,
  43. llvm::DenseMap<const CXXRecordDecl *, CharUnits> &BaseOffsets,
  44. llvm::DenseMap<const CXXRecordDecl *, CharUnits> &VirtualBaseOffsets) {
  45. return false;
  46. }
  47. Decl *ExternalASTSource::GetExternalDecl(uint32_t ID) {
  48. return nullptr;
  49. }
  50. Selector ExternalASTSource::GetExternalSelector(uint32_t ID) {
  51. return Selector();
  52. }
  53. uint32_t ExternalASTSource::GetNumExternalSelectors() {
  54. return 0;
  55. }
  56. Stmt *ExternalASTSource::GetExternalDeclStmt(uint64_t Offset) {
  57. return nullptr;
  58. }
  59. CXXCtorInitializer **
  60. ExternalASTSource::GetExternalCXXCtorInitializers(uint64_t Offset) {
  61. return nullptr;
  62. }
  63. CXXBaseSpecifier *
  64. ExternalASTSource::GetExternalCXXBaseSpecifiers(uint64_t Offset) {
  65. return nullptr;
  66. }
  67. bool
  68. ExternalASTSource::FindExternalVisibleDeclsByName(const DeclContext *DC,
  69. DeclarationName Name) {
  70. return false;
  71. }
  72. void ExternalASTSource::completeVisibleDeclsMap(const DeclContext *DC) {
  73. }
  74. ExternalLoadResult
  75. ExternalASTSource::FindExternalLexicalDecls(const DeclContext *DC,
  76. bool (*isKindWeWant)(Decl::Kind),
  77. SmallVectorImpl<Decl*> &Result) {
  78. return ELR_AlreadyLoaded;
  79. }
  80. void ExternalASTSource::getMemoryBufferSizes(MemoryBufferSizes &sizes) const { }
  81. uint32_t ExternalASTSource::incrementGeneration(ASTContext &C) {
  82. uint32_t OldGeneration = CurrentGeneration;
  83. // Make sure the generation of the topmost external source for the context is
  84. // incremented. That might not be us.
  85. auto *P = C.getExternalSource();
  86. if (P && P != this)
  87. CurrentGeneration = P->incrementGeneration(C);
  88. else {
  89. // FIXME: Only bump the generation counter if the current generation number
  90. // has been observed?
  91. if (!++CurrentGeneration)
  92. llvm::report_fatal_error("generation counter overflowed", false);
  93. }
  94. return OldGeneration;
  95. }