Skip to content

Commit 9804e23

Browse files
committed
Add headerFileInfor
1 parent 968e619 commit 9804e23

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

interpreter/cling/lib/Interpreter/IncrementalParser.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -856,6 +856,7 @@ namespace cling {
856856
// Add the input to the memory buffer, parse it, and add it to the AST.
857857
IncrementalParser::EParseResult
858858
IncrementalParser::ParseInternal(llvm::StringRef input) {
859+
llvm::errs() << "ParseInternal: " << input << "\n";
859860
if (input.empty()) return IncrementalParser::kSuccess;
860861

861862
Sema& S = getCI()->getSema();
@@ -897,9 +898,15 @@ namespace cling {
897898
FileID FID;
898899
// Create FileEntry and FileID for the current buffer.
899900
// Enabling the completion point only works on FileEntries.
901+
time_t FakeModTime = std::time(nullptr);
900902
FileEntryRef FE =
901903
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+
903910
SM.overrideFileContents(FE, std::move(MB));
904911
FID = SM.createFileID(FE, NewLoc, SrcMgr::C_User);
905912
if (CO.CodeCompletionOffset != -1) {
@@ -941,6 +948,7 @@ namespace cling {
941948
else if (Diags.getNumWarnings())
942949
return kSuccessWithWarnings;
943950

951+
llvm::errs() << "ParseInternal: done!\n";
944952
return kSuccess;
945953
}
946954

0 commit comments

Comments
 (0)