@@ -856,6 +856,7 @@ namespace cling {
856
856
// Add the input to the memory buffer, parse it, and add it to the AST.
857
857
IncrementalParser::EParseResult
858
858
IncrementalParser::ParseInternal (llvm::StringRef input) {
859
+ llvm::errs () << " ParseInternal: " << input << " \n " ;
859
860
if (input.empty ()) return IncrementalParser::kSuccess ;
860
861
861
862
Sema& S = getCI ()->getSema ();
@@ -897,9 +898,15 @@ namespace cling {
897
898
FileID FID;
898
899
// Create FileEntry and FileID for the current buffer.
899
900
// Enabling the completion point only works on FileEntries.
901
+ time_t FakeModTime = std::time (nullptr );
900
902
FileEntryRef FE =
901
903
SM.getFileManager ().getVirtualFileRef (source_name.str (), InputSize,
902
- 0 /* mod time*/ );
904
+ FakeModTime /* mod time*/ );
905
+ // Force creation of HeaderFileInfo for the virtual file.
906
+ // This ensures that when the virtual file is used as the includer,
907
+ // Clang will find a valid HeaderFileInfo.
908
+ m_CI->getPreprocessor ().getHeaderSearchInfo ().getFileInfo (FE);
909
+
903
910
SM.overrideFileContents (FE, std::move (MB));
904
911
FID = SM.createFileID (FE, NewLoc, SrcMgr::C_User);
905
912
if (CO.CodeCompletionOffset != -1 ) {
@@ -941,6 +948,7 @@ namespace cling {
941
948
else if (Diags.getNumWarnings ())
942
949
return kSuccessWithWarnings ;
943
950
951
+ llvm::errs () << " ParseInternal: done!\n " ;
944
952
return kSuccess ;
945
953
}
946
954
0 commit comments