Return early if FileID is invalid. NFC
authorAkira Hatanaka <ahatanaka@apple.com>
Thu, 15 Dec 2022 05:28:02 +0000 (21:28 -0800)
committerAkira Hatanaka <ahatanaka@apple.com>
Thu, 15 Dec 2022 05:28:31 +0000 (21:28 -0800)
clang/lib/Frontend/HeaderIncludeGen.cpp

index 30fe5c75b9ac3978b1eb40d77f44a8fb027ff4a5..2ab4809402645e6233fc04a698f3d0f996230d96 100644 (file)
@@ -291,7 +291,8 @@ static bool shouldRecordNewFile(SrcMgr::CharacteristicKind NewFileType,
 void HeaderIncludesJSONCallback::FileChanged(
     SourceLocation Loc, FileChangeReason Reason,
     SrcMgr::CharacteristicKind NewFileType, FileID PrevFID) {
-  if (!shouldRecordNewFile(NewFileType, SM.getLocForStartOfFile(PrevFID), SM))
+  if (PrevFID.isInvalid() ||
+      !shouldRecordNewFile(NewFileType, SM.getLocForStartOfFile(PrevFID), SM))
     return;
 
   // Unless we are exiting a #include, make sure to skip ahead to the line the