[clang-tools-extra] 5aae0ee - [clang-tidy] give dummy path when create ClangTidyContext (#134670)

via cfe-commits cfe-commits at lists.llvm.org
Mon Apr 7 19:47:42 PDT 2025


Author: Congcong Cai
Date: 2025-04-08T10:47:39+08:00
New Revision: 5aae0ee660ffdae057d7c5c0e851b5620586d042

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

LOG: [clang-tidy] give dummy path when create ClangTidyContext (#134670)

#121323 changed the way the absolute path is computed. Empty file name
will cause absolute path ignore current folder.
This patch add "dummy" file name to avoid this issue
Fixed: #134502

Added: 
    

Modified: 
    clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp

Removed: 
    


################################################################################
diff  --git a/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp b/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
index abd6d7b4cd60f..731141a545a48 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
+++ b/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
@@ -167,8 +167,8 @@ ClangTidyContext::ClangTidyContext(
       AllowEnablingAnalyzerAlphaCheckers(AllowEnablingAnalyzerAlphaCheckers),
       EnableModuleHeadersParsing(EnableModuleHeadersParsing) {
   // Before the first translation unit we can get errors related to command-line
-  // parsing, use empty string for the file name in this case.
-  setCurrentFile("");
+  // parsing, use dummy string for the file name in this case.
+  setCurrentFile("dummy");
 }
 
 ClangTidyContext::~ClangTidyContext() = default;


        


More information about the cfe-commits mailing list