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

Congcong Cai via cfe-commits cfe-commits at lists.llvm.org
Mon Apr 7 08:18:04 PDT 2025


https://github.com/HerrCai0907 created https://github.com/llvm/llvm-project/pull/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


>From 5849dd81015462d02e35ded330d619e91e488de9 Mon Sep 17 00:00:00 2001
From: Congcong Cai <congcongcai0907 at 163.com>
Date: Mon, 7 Apr 2025 15:13:23 +0000
Subject: [PATCH] [clang-tidy] give dummy path when create ClangTidyContext

#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
---
 clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp b/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
index 71e852545203e..f0c9881a48838 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
+++ b/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
@@ -166,8 +166,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