summaryrefslogtreecommitdiffstats
path: root/lib/Lex
diff options
context:
space:
mode:
authorEric Christopher <echristo@gmail.com>2018-09-20 17:21:56 +0000
committerEric Christopher <echristo@gmail.com>2018-09-20 17:21:56 +0000
commit3a5a6148d4a0855fd48d5aaba3556b4aa3a06dac (patch)
tree42f9db12a2800630e7586003f6bdeadf85afa967 /lib/Lex
parentf9cd06406d14c464d6a3d9c29b5bb508dd57ab8f (diff)
r342177 introduced a hint in cases where an #included file is not found. It tries to find a suggestion by removing leading or trailing non-alphanumeric characters and checking if a matching file exists, then it reports an error like:
include-likely-typo.c:3:10: error: '<empty_file_to_include.h>' file not found, did you mean 'empty_file_to_include.h'? ^~~~~~~~~~~~~~~~~~~~~~~~~~~ "empty_file_to_include.h" 1 error generated. However, if a hint is not found, the error message will show only the trimmed name we use to look for a hint, so: will result in: include-leading-nonalpha-no-suggest.c:3:10: fatal error: 'non_existing_file_to_include.h' file not found ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1 error generated. where the name reported after "fatal error:" doesn't match what the user wrote. Patch by Jorge Gorbe! Differential Revision: https://reviews.llvm.org/D52280 This change reports the original file name instead of the trimmed one when a suggestion is not found. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@342667 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Lex')
-rw-r--r--lib/Lex/PPDirectives.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/Lex/PPDirectives.cpp b/lib/Lex/PPDirectives.cpp
index ca2b3d5d02..00397e1e1a 100644
--- a/lib/Lex/PPDirectives.cpp
+++ b/lib/Lex/PPDirectives.cpp
@@ -1887,8 +1887,8 @@ void Preprocessor::HandleIncludeDirective(SourceLocation HashLoc,
// Check for likely typos due to leading or trailing non-isAlphanumeric
// characters
+ StringRef OriginalFilename = Filename;
if (!File) {
- StringRef OriginalFilename = Filename;
while (!isAlphanumeric(Filename.front())) {
Filename = Filename.drop_front();
}
@@ -1915,7 +1915,7 @@ void Preprocessor::HandleIncludeDirective(SourceLocation HashLoc,
// If the file is still not found, just go with the vanilla diagnostic
if (!File)
- Diag(FilenameTok, diag::err_pp_file_not_found) << Filename
+ Diag(FilenameTok, diag::err_pp_file_not_found) << OriginalFilename
<< FilenameRange;
}
}