Skip to content
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

"In file included from" lines don't respect -fdiagnostics-absolute-paths #63026

Closed
stk-ableton opened this issue May 31, 2023 · 4 comments
Closed
Assignees
Labels
clang:diagnostics New/improved warning or error message in Clang, but not in clang-tidy or static analyzer good first issue https://github.com/llvm/llvm-project/contribute

Comments

@stk-ableton
Copy link

stk-ableton commented May 31, 2023

The "In file included from ..." lines of diagnostics contain relative paths even when -fdiagnostics-absolute-paths is given.

Reproduction:

mkdir /tmp/clang-test
cd /tmp/clang-test
echo '#include "x.h"' >x.cpp
echo '#warning abc' >x.h
clang++ -fdiagnostics-absolute-paths x.cpp

Current output:

In file included from x.cpp:1:
/tmp/clang-test/x.h:1:2: warning: abc [-W#warnings]

Expected output:

In file included from /tmp/clang-test/x.cpp:1:
/tmp/clang-test/x.h:1:2: warning: abc [-W#warnings]
@tbaederr tbaederr added clang:diagnostics New/improved warning or error message in Clang, but not in clang-tidy or static analyzer and removed new issue labels May 31, 2023
@tbaederr
Copy link
Contributor

Looking at the code:

void TextDiagnostic::emitIncludeLocation(FullSourceLoc Loc, PresumedLoc PLoc) {
if (DiagOpts->ShowLocation && PLoc.isValid())
OS << "In file included from " << PLoc.getFilename() << ':'
<< PLoc.getLine() << ":\n";
else
OS << "In included file:\n";
}
void TextDiagnostic::emitImportLocation(FullSourceLoc Loc, PresumedLoc PLoc,
StringRef ModuleName) {
if (DiagOpts->ShowLocation && PLoc.isValid())
OS << "In module '" << ModuleName << "' imported from "
<< PLoc.getFilename() << ':' << PLoc.getLine() << ":\n";
else
OS << "In module '" << ModuleName << "':\n";
}
void TextDiagnostic::emitBuildingModuleLocation(FullSourceLoc Loc,
PresumedLoc PLoc,
StringRef ModuleName) {
if (DiagOpts->ShowLocation && PLoc.isValid())
OS << "While building module '" << ModuleName << "' imported from "
<< PLoc.getFilename() << ':' << PLoc.getLine() << ":\n";
else
OS << "While building module '" << ModuleName << "':\n";
}

this is also the case for the corresponding module output. DiagOpts->AbsolutePath is handled in this file as well.

@tbaederr tbaederr added the good first issue https://github.com/llvm/llvm-project/contribute label May 31, 2023
@llvmbot
Copy link
Collaborator

llvmbot commented May 31, 2023

Hi!

This issue may be a good introductory issue for people new to working on LLVM. If you would like to work on this issue, your first steps are:

  1. Assign the issue to you.
  2. Fix the issue locally.
  3. Run the test suite locally.
    3.1) Remember that the subdirectories under test/ create fine-grained testing targets, so you can
    e.g. use make check-clang-ast to only run Clang's AST tests.
  4. Create a git commit
  5. Run git clang-format HEAD~1 to format your changes.
  6. Submit the patch to Phabricator.
    6.1) Detailed instructions can be found here

For more instructions on how to submit a patch to LLVM, see our documentation.

If you have any further questions about this issue, don't hesitate to ask via a comment on this Github issue.

@llvm/issue-subscribers-good-first-issue

@charmitro
Copy link
Contributor

Hello, I would like to work on this issue.

@charmitro
Copy link
Contributor

Patch sent at https://reviews.llvm.org/D151833

@cjdb cjdb closed this as completed in 91be60b Jun 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:diagnostics New/improved warning or error message in Clang, but not in clang-tidy or static analyzer good first issue https://github.com/llvm/llvm-project/contribute
Projects
None yet
Development

No branches or pull requests

4 participants