@@ -35,7 +35,8 @@ class IncludeStructure::RecordHeaders : public PPCallbacks,
35
35
void InclusionDirective (SourceLocation HashLoc, const Token &IncludeTok,
36
36
llvm::StringRef FileName, bool IsAngled,
37
37
CharSourceRange /* FilenameRange*/ ,
38
- const FileEntry *File, llvm::StringRef /* SearchPath*/ ,
38
+ Optional<FileEntryRef> File,
39
+ llvm::StringRef /* SearchPath*/ ,
39
40
llvm::StringRef /* RelativePath*/ ,
40
41
const clang::Module * /* Imported*/ ,
41
42
SrcMgr::CharacteristicKind FileKind) override {
@@ -51,7 +52,8 @@ class IncludeStructure::RecordHeaders : public PPCallbacks,
51
52
auto &Inc = Out->MainFileIncludes .back ();
52
53
Inc.Written =
53
54
(IsAngled ? " <" + FileName + " >" : " \" " + FileName + " \" " ).str ();
54
- Inc.Resolved = std::string (File ? File->tryGetRealPathName () : " " );
55
+ Inc.Resolved =
56
+ std::string (File ? File->getFileEntry ().tryGetRealPathName () : " " );
55
57
Inc.HashOffset = SM.getFileOffset (HashLoc);
56
58
Inc.HashLine =
57
59
SM.getLineNumber (SM.getFileID (HashLoc), Inc.HashOffset ) - 1 ;
@@ -60,7 +62,7 @@ class IncludeStructure::RecordHeaders : public PPCallbacks,
60
62
if (LastPragmaKeepInMainFileLine == Inc.HashLine )
61
63
Inc.BehindPragmaKeep = true ;
62
64
if (File) {
63
- IncludeStructure::HeaderID HID = Out->getOrCreateID (File);
65
+ IncludeStructure::HeaderID HID = Out->getOrCreateID (* File);
64
66
Inc.HeaderID = static_cast <unsigned >(HID);
65
67
if (IsAngled)
66
68
if (auto StdlibHeader = tooling::stdlib::Header::named (Inc.Written )) {
@@ -74,15 +76,15 @@ class IncludeStructure::RecordHeaders : public PPCallbacks,
74
76
75
77
// Record include graph (not just for main-file includes)
76
78
if (File) {
77
- auto * IncludingFileEntry = SM.getFileEntryForID (SM.getFileID (HashLoc));
79
+ auto IncludingFileEntry = SM.getFileEntryRefForID (SM.getFileID (HashLoc));
78
80
if (!IncludingFileEntry) {
79
81
assert (SM.getBufferName (HashLoc).startswith (" <" ) &&
80
82
" Expected #include location to be a file or <built-in>" );
81
83
// Treat as if included from the main file.
82
- IncludingFileEntry = SM.getFileEntryForID (MainFID);
84
+ IncludingFileEntry = SM.getFileEntryRefForID (MainFID);
83
85
}
84
- auto IncludingID = Out->getOrCreateID (IncludingFileEntry),
85
- IncludedID = Out->getOrCreateID (File);
86
+ auto IncludingID = Out->getOrCreateID (* IncludingFileEntry),
87
+ IncludedID = Out->getOrCreateID (* File);
86
88
Out->IncludeChildren [IncludingID].push_back (IncludedID);
87
89
}
88
90
}
@@ -226,22 +228,22 @@ IncludeStructure::getID(const FileEntry *Entry) const {
226
228
}
227
229
228
230
IncludeStructure::HeaderID
229
- IncludeStructure::getOrCreateID (const FileEntry * Entry) {
231
+ IncludeStructure::getOrCreateID (FileEntryRef Entry) {
230
232
// Main file's FileEntry was not known at IncludeStructure creation time.
231
- if (Entry == MainFileEntry) {
233
+ if (& Entry. getFileEntry () == MainFileEntry) {
232
234
if (RealPathNames.front ().empty ())
233
235
RealPathNames.front () = MainFileEntry->tryGetRealPathName ().str ();
234
236
return MainFileID;
235
237
}
236
238
auto R = UIDToIndex.try_emplace (
237
- Entry-> getUniqueID (),
239
+ Entry. getUniqueID (),
238
240
static_cast <IncludeStructure::HeaderID>(RealPathNames.size ()));
239
241
if (R.second )
240
242
RealPathNames.emplace_back ();
241
243
IncludeStructure::HeaderID Result = R.first ->getSecond ();
242
244
std::string &RealPathName = RealPathNames[static_cast <unsigned >(Result)];
243
245
if (RealPathName.empty ())
244
- RealPathName = Entry-> tryGetRealPathName ().str ();
246
+ RealPathName = Entry. getFileEntry (). tryGetRealPathName ().str ();
245
247
return Result;
246
248
}
247
249
0 commit comments