Index: include/clang/Basic/DiagnosticLexKinds.td =================================================================== --- include/clang/Basic/DiagnosticLexKinds.td +++ include/clang/Basic/DiagnosticLexKinds.td @@ -471,6 +471,10 @@ def err_pp_identifier_arg_not_identifier : Error< "cannot convert %0 token to an identifier">; +def warn_pp_filename_likely_typo : + ExtWarn<"likely typo, expected \"FILENAME\" or " + "but filename is '%0'">, InGroup; + def warn_pragma_include_alias_mismatch_angle : ExtWarn<"angle-bracketed include <%0> cannot be aliased to double-quoted " "include \"%1\"">, InGroup; Index: lib/Lex/PPDirectives.cpp =================================================================== --- lib/Lex/PPDirectives.cpp +++ lib/Lex/PPDirectives.cpp @@ -1875,9 +1875,16 @@ } // If the file is still not found, just go with the vanilla diagnostic - if (!File) - Diag(FilenameTok, diag::err_pp_file_not_found) << Filename - << FilenameRange; + if (!File) { + // Assuming filename logically starts and end with alphnumeric + // character + if (!isAlphanumeric(Filename.front()) || + !isAlphanumeric(Filename.back())) { + Diag(FilenameTok, diag::warn_pp_filename_likely_typo) << Filename; + } + Diag(FilenameTok, diag::err_pp_file_not_found) + << Filename << FilenameRange; + } } } Index: test/Frontend/include-likely-typo.c =================================================================== --- /dev/null +++ test/Frontend/include-likely-typo.c @@ -0,0 +1,4 @@ +// RUN: not %clang_cc1 -verify -frewrite-includes +#include "" @expected-warning {{likely typo, expected "FILENAME" or but filename is ''}} +@expected-error {{'' file not found}} +#include " hello.h " @expected-warning {{likely typo, expected "FILENAME" or but filename is ' hello.h '}}