Skip to content

[clang-tidy] give dummy path when create ClangTidyContext #134670

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

HerrCai0907
Copy link
Contributor

#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

llvm#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: llvm#134502
@llvmbot
Copy link
Member

llvmbot commented Apr 7, 2025

@llvm/pr-subscribers-clang-tidy

@llvm/pr-subscribers-clang-tools-extra

Author: Congcong Cai (HerrCai0907)

Changes

#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


Full diff: https://github.com/llvm/llvm-project/pull/134670.diff

1 Files Affected:

  • (modified) clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp (+2-2)
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;

@HerrCai0907 HerrCai0907 marked this pull request as draft April 7, 2025 15:20
Copy link
Contributor

@carlosgalvezp carlosgalvezp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should work, thanks! I still feel the whole framework needs a bit of refactoring, the logic and data flow is a bit hidden and it's hard to spot these dependencies that break because things are done in the wrong order.

@HerrCai0907 HerrCai0907 marked this pull request as ready for review April 8, 2025 02:47
@HerrCai0907 HerrCai0907 merged commit 5aae0ee into llvm:main Apr 8, 2025
16 checks passed
@HerrCai0907 HerrCai0907 deleted the 134502-clang-tidy-fix-fileconfigoptionsprovidergetoptions branch April 8, 2025 02:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[clang-tidy] Fix [File|Config]OptionsProvider::getOptions
3 participants