示例#1
0
    void InsertIntoAutoloadingState (Decl* decl, std::string annotation) {

      assert(annotation != "" && "Empty annotation!");
      assert(m_PP);

      const FileEntry* FE = 0;
      SourceLocation fileNameLoc;
      bool isAngled = false;
      const DirectoryLookup* LookupFrom = 0;
      const DirectoryLookup* CurDir = 0;

      FE = m_PP->LookupFile(fileNameLoc, annotation, isAngled, LookupFrom,
                            CurDir, /*SearchPath*/0, /*RelativePath*/ 0,
                            /*suggestedModule*/0, /*SkipCache*/false,
                            /*OpenFile*/ false, /*CacheFail*/ false);

      assert(FE && "Must have a valid FileEntry");

      if (m_Map->find(FE) == m_Map->end())
        (*m_Map)[FE] = std::vector<Decl*>();

      (*m_Map)[FE].push_back(decl);
    }
示例#2
0
    void InsertIntoAutoloadingState(Decl* decl, Annotations_t FileNames) {

      assert(m_PP);

      auto addFile = [this,decl](llvm::StringRef FileName, bool warn) {
        if (FileName.empty()) return (const FileEntry*)nullptr;

        const FileEntry* FE = 0;
        SourceLocation fileNameLoc;
        // Remember this file wth full path, not "./File.h" (ROOT-8863).
        bool isAngled = true;
        const DirectoryLookup* FromDir = 0;
        const FileEntry* FromFile = 0;
        const DirectoryLookup* CurDir = 0;
        bool needCacheUpdate = false;

        if (FileName.equals(m_PrevFileName.first))
          FE = m_PrevFE.first;
        else if (FileName.equals(m_PrevFileName.second))
          FE = m_PrevFE.second;
        else {
          FE = m_PP->LookupFile(fileNameLoc, FileName, isAngled,
                                FromDir, FromFile, CurDir, /*SearchPath*/0,
                                /*RelativePath*/ 0, /*suggestedModule*/0,
                                /*IsMapped*/0, /*SkipCache*/ false,
                                /*OpenFile*/ false, /*CacheFail*/ true);
          needCacheUpdate = true;
        }

        if (FE) {
          auto& Vec = (*m_Map)[FE];
          Vec.push_back(decl);
          if (needCacheUpdate) return FE;
          else return (const FileEntry*)nullptr;
        } else if (warn) {
          // If the top level header is expected to be findable at run-time,
          // the direct header might not because the include path might be
          // different enough and only the top-header is guaranteed to be seen
          // by the user as an interface header to be available on the
          // run-time include path.
          cling::errs()
          << "Error in cling::AutoloadingVisitor::InsertIntoAutoloadingState:\n"
          "   Missing FileEntry for " << FileName << "\n";
          if (NamedDecl* ND = dyn_cast<NamedDecl>(decl)) {
            cling::errs() << "   requested to autoload type ";
            ND->getNameForDiagnostic(cling::errs(),
                                     ND->getASTContext().getPrintingPolicy(),
                                     true /*qualified*/);
            cling::errs() << "\n";
          }
          return (const FileEntry*)nullptr;
        } else {
          // Case of the direct header that is not a top level header, no
          // warning in this case (to likely to be a false positive).
          return (const FileEntry*)nullptr;
        }
      };

      const FileEntry* cacheUpdate;

      if ( (cacheUpdate = addFile(FileNames.first,true)) ) {
        m_PrevFE.first = cacheUpdate;
        m_PrevFileName.first = FileNames.first;
      }
      if ( (cacheUpdate = addFile(FileNames.second,false)) ) {
        m_PrevFE.second = cacheUpdate;
        m_PrevFileName.second = FileNames.second;
      }


    }