[PATCH] D45815: [libclang] Add options to limit skipping of function bodies

Ilya Biryukov via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 24 03:03:55 PDT 2018


ilya-biryukov added inline comments.


================
Comment at: include/clang/Frontend/ASTUnit.h:679
+  struct SkipFunctionBodiesOptions {
+    SkipFunctionBodiesOptions() {}
+    enum { None, MainFileAndPreamble, Preamble } Scope = None;
----------------
Default ctor will be generated automatically. Maybe remove explicit definition?


================
Comment at: include/clang/Frontend/FrontendOptions.h:302
 
+  SkipFunctionBodiesKind SkipFunctionBodies;
+
----------------
Maybe add a comment to match the code style of other options?


================
Comment at: lib/Frontend/ASTUnit.cpp:1662
+    {
+      SkipFunctionBodiesModifierRAII m(Invocation->getFrontendOpts(),
+                                       SkipFunctionBodiesOpts);
----------------
Maybe use LLVM's `make_scope_exit` from `ADT/ScopeExit.h` instead of creating a separate RAII class?
Or even directy set/restore the value of the flag right in the function.
Given that LLVM does not use exceptions, RAII class does not seem to buy much in terms of correctness and doesn't really make the code easier to read, IMO.

But up to you.


================
Comment at: lib/Parse/Parser.cpp:1107
 
+  bool SkipFunctionBodyRequested = false;
+  switch (SkipFunctionBodies) {
----------------
`Requested` in this name is a bit confusing, e.g. it's not clear who requested it.
Maybe rename to `TrySkipFunctionBody` or something similar?


Repository:
  rC Clang

https://reviews.llvm.org/D45815





More information about the cfe-commits mailing list