[PATCH] D49736: [Basic] Emit warning flag suggestion only in case there's *similar* existing flag for given unknown one

Jan Korous via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jul 24 08:24:05 PDT 2018


jkorous created this revision.
jkorous added reviewers: arphaman, vsapsai, bruno, JDevlieghere.
Herald added subscribers: cfe-commits, dexonsmith.

In case user specified non-existent warning flag clang was suggesting an existing on that was in some cased very different. This patch should ensure that either a relevant warning flag is suggested or none (which is in line with unknown generic command line option handling).

  Examples:
  warning: unknown warning option '-Whiskey'; did you mean '-Wpacked'?
  warning: unknown warning option '-Weverthin'; did you mean '-Wsection'?
  
  rdar://problem/37755482

I changed interface of DiagnosticIDs::getNearestOption() to return the edit distance between nonexistent flag and the closest exiting one. In principle this code is analogous to OptTable::findNearest() for generic command line options but I don't find them similar enough in order to factor out some shared implementation. I tentatively selected maximum edit distance as 2 (CompilerInvocation::CreateFromArgs() uses maximum edit distance of 1 for generic case).


Repository:
  rC Clang

https://reviews.llvm.org/D49736

Files:
  Basic/DiagnosticIDs.cpp
  Basic/Warnings.cpp
  Driver/cc-log-diagnostics.c
  Frontend/warning-options.cpp
  clang/Basic/DiagnosticIDs.h

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D49736.157042.patch
Type: text/x-patch
Size: 4480 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180724/9fc4151d/attachment.bin>


More information about the cfe-commits mailing list