Diagnose likely typos in #include directives.
authorRichard Smith <richard-llvm@metafoo.co.uk>
Thu, 13 Sep 2018 21:10:08 +0000 (21:10 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Thu, 13 Sep 2018 21:10:08 +0000 (21:10 +0000)
commit2ce63b4246329ee0fb20aa6f768f1f57eda6d5f0
tree4be210b1e56cdc21224b46cb709dbf767159f538
parent2f88006cedd06b8e2be1e9d282ba7e3bf88f57ca
Diagnose likely typos in #include directives.

Summary:
When someone writes

  #include "<some_file>"

or

  #include " some_file "

the compiler returns "file not fuond..." with fonts and quotes that may
make it hard to see there are excess quotes or surprising bytes in the
filename.  Assuming that files are usually logically named and start and
end with an alphanumeric character, we can check for the file's
existence by stripping the non-alphanumeric leading or trailing
characters.  If the file is found, emit a non-fatal error with a
FixItHint.

Patch by Christy Lee!

Reviewers: aaron.ballman, erikjv, rsmith

Reviewed By: rsmith

Subscribers: lebedev.ri, xbolva00, sammccall, modocache, erikjv, aaron.ballman, cfe-commits

Differential Revision: https://reviews.llvm.org/D51333

llvm-svn: 342177
clang/include/clang/Basic/DiagnosticLexKinds.td
clang/lib/Lex/PPDirectives.cpp
clang/test/Preprocessor/empty_file_to_include.h [new file with mode: 0644]
clang/test/Preprocessor/include-likely-typo.c [new file with mode: 0644]