[PATCH] D33275: Keep into account if files were virtual.

Vassil Vassilev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed May 17 14:47:42 PDT 2017


v.g.vassilev added a comment.

We have this pattern:

  FileID FID;
  const clang::FileEntry* FE
    = SM.getFileManager().getVirtualFile(source_name.str(), InputSize,
                                         0 /* mod time*/);
  SM.overrideFileContents(FE, std::move(MB)); // MB is a llvm::MemoryBuffer
  FID = SM.createFileID(FE, NewLoc, SrcMgr::C_User);
  
  ...
  
  PP.EnterSourceFile(FID, /*DirLookup*/0, NewLoc); // PP is a clang::Preprocessor

If the memory buffer contains eg. '//expected-error: ...' this forces the ContentCache to compute some source location information IIRC. This leads in hitting the disk, ignoring the fact that this is a virtual file with an overridden content.

I will try to come up with a test but I may need to land some interpreter infrastructure first...


https://reviews.llvm.org/D33275





More information about the cfe-commits mailing list