[clang-tools-extra] f3314e3 - [clang-tidy] Pop Files only if FileChangeReason is ExitFile

Jim Lin via cfe-commits cfe-commits at lists.llvm.org
Tue Jan 25 06:43:33 PST 2022


Author: Jim Lin
Date: 2022-01-25T22:46:12+08:00
New Revision: f3314e3747873fdf026a28742a30f372503baf32

URL: https://github.com/llvm/llvm-project/commit/f3314e3747873fdf026a28742a30f372503baf32
DIFF: https://github.com/llvm/llvm-project/commit/f3314e3747873fdf026a28742a30f372503baf32.diff

LOG: [clang-tidy] Pop Files only if FileChangeReason is ExitFile

enum FileChangeReason has four possible type EnterFile, ExitFile,
SystemHeaderPragma and RenameFile,
It should pop the back element of Files only if FileChangeReason is ExitFile.

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/clang-tools-extra/clang-tidy/readability/DuplicateIncludeCheck.cpp b/clang-tools-extra/clang-tidy/readability/DuplicateIncludeCheck.cpp
index 681b8399154a7..a6e49439c8434 100644
--- a/clang-tools-extra/clang-tidy/readability/DuplicateIncludeCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/DuplicateIncludeCheck.cpp
@@ -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();
 }
 


        


More information about the cfe-commits mailing list