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

Incorrect range of <angled> include fixit #14252

Closed
llvmbot opened this issue Sep 20, 2012 · 5 comments
Closed

Incorrect range of <angled> include fixit #14252

llvmbot opened this issue Sep 20, 2012 · 5 comments
Labels
bugzilla Issues migrated from bugzilla

Comments

@llvmbot
Copy link
Collaborator

llvmbot commented Sep 20, 2012

Bugzilla Link 13880
Resolution FIXED
Resolved on Sep 30, 2012 15:21
Version trunk
OS MacOS X
Reporter LLVM Bugzilla Contributor
CC @akyrtzi,@efriedma-quic,@zygoloid

Extended Description

Steps to Reproduce:
In llvm/tools/clang/test/FixIt run
$ clang -fsyntax-only fixit-include.c

Actual Results:
fixit-include.c:7:10: error: 'fixit-include.h' file not found with include; use "quotes" instead
#include <fixit-include.h> // expected-error {{'fixit-include.h' file not found with include; use "quotes" instead}}
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"fixit-include.h"
1 error generated.

Expected Results:
fixit-include.c:7:10: error: 'fixit-include.h' file not found with include; use "quotes" instead
#include <fixit-include.h> // expected-error {{'fixit-include.h' file not found with include; use "quotes" instead}}
^~~~~~~~~~~~~~~~~
"fixit-include.h"
1 error generated.

I.e. fixit range shouldn't go beyond right angled bracket.

Build Date & Platform:
Build 09/20/2012 (r164256) on Mac OS X 10.6.8.

@zygoloid
Copy link
Mannequin

zygoloid mannequin commented Sep 20, 2012

This was caused by r163588.

@llvmbot
Copy link
Collaborator Author

llvmbot commented Sep 20, 2012

Use in InclusionDirective separate location variable pointing before >
Looks like this bug was introduced in r163588: in lib/Lex/PPDirectives.cpp by

case tok::angle_string_literal:
case tok::string_literal:
Filename = getSpelling(FilenameTok, FilenameBuffer);
End = FilenameTok.getLocation();

  • // For an angled include, point the end location at the closing '>'.
  • if (FilenameTok.is(tok::angle_string_literal))
  • End = End.getLocWithOffset(Filename.size()-1);
    
    CharEnd = End.getLocWithOffset(Filename.size());
    break;

Later CharEnd is used to compute fixit range, causing too long range. Also the same problem should be present for @​__experimental_modules_import fixit, but I didn't try to reproduce it.

I'd like to note that mentioned change also causes clang::SourceManager::getIncludeLoc(FileID FID) const to return location pointing at '>'. But for include-what-you-use tool I need to get include name as typed and it was convenient when getIncludeLoc() returned location pointing at '<' or '"' (opening quotation mark).

I've created a patch according to my getIncludeLoc() preferences which fixes this issue. Please find patch attached.

@zygoloid
Copy link
Mannequin

zygoloid mannequin commented Sep 20, 2012

We're already in discussion about the right way to fix this:

http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20120917/064551.html

@akyrtzi
Copy link
Contributor

akyrtzi commented Sep 27, 2012

Fixed in r164743.

@llvmbot
Copy link
Collaborator Author

llvmbot commented Sep 30, 2012

Confirm that bug is fixed. Should I change the issue state to VERIFIED or CLOSED?

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 3, 2021
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla
Projects
None yet
Development

No branches or pull requests

2 participants