This is an archive of the discontinued LLVM Phabricator instance.

[Bash-autocompletion] Add support for -W<warning> and -Wno<warning>
ClosedPublic

Authored by yamaguchi on Jul 14 2017, 10:27 PM.

Event Timeline

yamaguchi created this revision.Jul 14 2017, 10:27 PM
ruiu added inline comments.Jul 14 2017, 10:47 PM
clang/include/clang/Basic/DiagnosticIDs.h
267

Please write a function comment just like other member functions in this class.

clang/lib/Basic/DiagnosticIDs.cpp
514

res -> Res
i -> I

515

size_t is more precise than int, even though sizeof(DiagGroupNames) in reality fits in an int.

516–517

If you want to construct a string, you can do this

std::string Diag(DiagGroupNames + i + 1, DiagGroupNames[i]);
519–522

I think you can remove these temporary variables:

res.push_back("-W" + Diag);
res.push_back("-Wno" + Diag);
clang/lib/Driver/Driver.cpp
1279

Let's avoid copy: std::string -> StringRef

teemperor requested changes to this revision.Jul 15 2017, 12:34 AM

It seems the code doesn't compile in clang because on your platform std::vector is implicitly included by some header, on clang+Arch however it isn`t (see the error at the end of https://teemperor.de/ccir/D35447).

clang/lib/Driver/Driver.cpp
1279

Could you document why we had to do it this way and can't reuse the normal flags? Maybe even add a TODO: because it would be nice project for someone to refactor this into one data structure.

This revision now requires changes to proceed.Jul 15 2017, 12:34 AM

@teemperor
I forgot to include <vector> in DiagnosticIDs, thanks!

What do you mean reuse the normal flags ?
Do you think we should define these -W<warnings> in Options.td like other flags?

@yamaguchi yes, the reason why we have to treat the -W... flags specially should be documented (as they're not in the OptTable as you said). E.g. something like // We have to query the -W flags manually as they're not in the OptTable. and then maybe a TODO: Find a good way to add them to OptTable instead and them remove this code..

yamaguchi updated this revision to Diff 106763.Jul 15 2017, 2:38 AM
yamaguchi edited edge metadata.

Update diff according to Rui and teemperor's comments.

yamaguchi updated this revision to Diff 106764.Jul 15 2017, 2:41 AM

Add code comment.

yamaguchi updated this revision to Diff 106774.Jul 15 2017, 9:23 AM

Fixed indent.

teemperor accepted this revision.Jul 15 2017, 12:13 PM

I have a last request in my inline comment regarding the documentation, otherwise this is good to go. Nice work!

clang/include/clang/Basic/DiagnosticIDs.h
267

Let's add an example to make it clear that we want to have the command line flags here, something like this:

/// \brief Get the list of all diagnostic flags.
/// \returns A list of all diagnostics flags as they would be written in a command line invocation
///          including their `no-` variants. For example: `{"-Wempty-body", "-Wno-empty-body", ...}`
This revision is now accepted and ready to land.Jul 15 2017, 12:13 PM
ruiu accepted this revision.Jul 15 2017, 12:15 PM

LGTM

clang/lib/Driver/Driver.cpp
1283

nit: StringRef(S) -> S as S is already a StringRef.

This revision was automatically updated to reflect the committed changes.