[PATCH] D104439: [analyzer][NFC] Demonstrate a move from the analyzer-configs `.def` file to a TableGen file
Balázs Benics via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Mar 24 06:43:59 PDT 2022
steakhal added reviewers: jansvoboda11, myhsu.
steakhal added subscribers: jansvoboda11, myhsu.
steakhal added a comment.
Herald added a project: All.
> We can put all the acceptable values in the help text AND generate the enum class WITHOUT any redundancy.
+1
> While not demonstrated, it'd be easy to add help texts to the enum values as well.
Ah yes! We should take it one step further. Generate user-facing documentation from the descriptions embedded in the `td file.
We should really have a doc page for analyzer configs as well, similarly to the one we have for checkers.
That being said, I would vote for generating the checker's user-facing docs as well, from the `Checkers.td` file. That way they would be always in sync and we could easily check if an option/checker is not documented.`
> Automatic initialization and validation of the user input can be done by marshaling, but its so strongly tied to regular llvm/clang flags, I'd rather use it as a source of inspiration.
I think we can introduce //marshaling// and `cl::opts` in a subsequent patch if we need to, but I cannot immediately foresee the impact of any of these.
Let me invite @myhsu for Tablegen and @jansvoboda11 for marshaling.
================
Comment at: clang/include/clang/StaticAnalyzer/AnalyzerFlagsBase.td:9
+
+/// Describes ain option type. This is important for validating user supplied
+/// inputs.
----------------
typo
================
Comment at: clang/utils/TableGen/ClangSAConfigsEmitter.cpp:19
+#include "llvm/TableGen/TableGenBackend.h"
+#include <map>
+#include <string>
----------------
Where do you use `std::map`?
================
Comment at: clang/utils/TableGen/ClangSAConfigsEmitter.cpp:35-38
+ if (DefaultVal == "")
+ OS << "\"\"";
+ else
+ OS << "\"" << DefaultVal << "\"";
----------------
================
Comment at: clang/utils/TableGen/ClangSAConfigsEmitter.cpp:43-49
+static SortedRecords getSortedDerivedDefinitions(RecordKeeper &Records,
+ StringRef ClassName) {
+ SortedRecords Ret;
+ for (const Record *R : Records.getAllDerivedDefinitions(ClassName))
+ Ret[R->getValueAsString("Name")] = R;
+ return Ret;
+}
----------------
How does this return a sorted data structure? `SortedRecords` aliases `llvm::StringMap<const Record *>`.
================
Comment at: clang/utils/TableGen/ClangSAConfigsEmitter.cpp:114
+
+ // Emit enum options. These are string options can only take a select fe
+ // values, and are parsed into enums.
----------------
typo
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D104439/new/
https://reviews.llvm.org/D104439
More information about the cfe-commits
mailing list