[PATCH] D36782: [Bash-autocompletion] Add support for static analyzer flags
Raphael Isemann via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Aug 16 02:48:28 PDT 2017
teemperor added inline comments.
================
Comment at: clang/lib/Driver/DriverOptions.cpp:14
#include "llvm/Option/Option.h"
+#include <assert.h>
----------------
I think the C++ version of the assert header is more consistent: `#include <cassert>`
================
Comment at: llvm/utils/TableGen/OptParserEmitter.cpp:313
+ for (const std::string &Pref : R.getValueAsListOfStrings("Prefixes")) {
+ OS << "assert(";
+ OS << "Opt.addValues(";
----------------
Don't call this inside an assert itself. The call would be removed on release builds (where assert is a no-op) and we wouldn't do the `addValues` anymore which breaks everything silently in release builds. Try something like this:
```
bool ValuesWereAdded = Opt.addValues(...);
(void)ValuesWereAdded; // Prevents unused variable warnings
assert(ValuesWereAdded && "Couldn't add values to OptTable!");
```
https://reviews.llvm.org/D36782
More information about the cfe-commits
mailing list