[clang-tidy] Pop Files only if FileChangeReason is ExitFile
authorJim Lin <jim@andestech.com>
Tue, 25 Jan 2022 07:05:43 +0000 (15:05 +0800)
committerJim Lin <jim@andestech.com>
Tue, 25 Jan 2022 14:46:12 +0000 (22:46 +0800)
enum FileChangeReason has four possible type EnterFile, ExitFile,
SystemHeaderPragma and RenameFile,
It should pop the back element of Files only if FileChangeReason is ExitFile.

clang-tools-extra/clang-tidy/readability/DuplicateIncludeCheck.cpp

index 681b839..a6e4943 100644 (file)
@@ -71,7 +71,7 @@ void DuplicateIncludeCallbacks::FileChanged(SourceLocation Loc,
                                             FileID PrevFID) {
   if (Reason == EnterFile)
     Files.emplace_back();
-  else
+  else if (Reason == ExitFile)
     Files.pop_back();
 }