aeubanks updated this revision to Diff 380847. aeubanks added a comment. use BoolOption td files are very hard to use...
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D112100/new/ https://reviews.llvm.org/D112100 Files: clang/include/clang/Driver/Options.td clang/lib/CodeGen/CodeGenAction.cpp clang/test/Misc/clear-ast-before-backend.c Index: clang/test/Misc/clear-ast-before-backend.c =================================================================== --- clang/test/Misc/clear-ast-before-backend.c +++ clang/test/Misc/clear-ast-before-backend.c @@ -1,9 +1,14 @@ -// RUN: %clang_cc1 -clear-ast-before-backend %s -emit-obj -o /dev/null -O1 -// RUN: %clang_cc1 -clear-ast-before-backend %s -emit-obj -o /dev/null -print-stats 2>&1 | FileCheck %s +// REQUIRES: asserts -// CHECK: *** Decl Stats: -// CHECK: {{.*}} decls total -// CHECK: 1 Function decls -// CHECK: Total bytes = +// RUN: %clang_cc1 -mllvm -debug-only=codegenaction -clear-ast-before-backend %s -emit-obj -o /dev/null -O1 2>&1 | FileCheck %s --check-prefix=YES +// RUN: %clang_cc1 -mllvm -debug-only=codegenaction -clear-ast-before-backend -no-clear-ast-before-backend %s -emit-obj -o /dev/null -O1 2>&1 | FileCheck %s --allow-empty --check-prefix=NO +// RUN: %clang_cc1 -clear-ast-before-backend %s -emit-obj -o /dev/null -print-stats 2>&1 | FileCheck %s --check-prefix=STATS + +// YES: Clearing AST +// NO-NOT: Clearing AST +// STATS: *** Decl Stats: +// STATS: {{.*}} decls total +// STATS: 1 Function decls +// STATS: Total bytes = void f() {} Index: clang/lib/CodeGen/CodeGenAction.cpp =================================================================== --- clang/lib/CodeGen/CodeGenAction.cpp +++ clang/lib/CodeGen/CodeGenAction.cpp @@ -52,6 +52,8 @@ using namespace clang; using namespace llvm; +#define DEBUG_TYPE "codegenaction" + namespace clang { class BackendConsumer; class ClangDiagnosticHandler final : public DiagnosticHandler { @@ -352,6 +354,7 @@ } if (CodeGenOpts.ClearASTBeforeBackend) { + LLVM_DEBUG(llvm::dbgs() << "Clearing AST...\n"); // Access to the AST is no longer available after this. // Other things that the ASTContext manages are still available, e.g. // the SourceManager. It'd be nice if we could separate out all the Index: clang/include/clang/Driver/Options.td =================================================================== --- clang/include/clang/Driver/Options.td +++ clang/include/clang/Driver/Options.td @@ -5311,9 +5311,11 @@ def disable_free : Flag<["-"], "disable-free">, HelpText<"Disable freeing of memory on exit">, MarshallingInfoFlag<FrontendOpts<"DisableFree">>; -def clear_ast_before_backend : Flag<["-"], "clear-ast-before-backend">, - HelpText<"Clear the Clang AST before running backend code generation">, - MarshallingInfoFlag<CodeGenOpts<"ClearASTBeforeBackend">>; +defm clear_ast_before_backend : BoolOption<"", "clear-ast-before-backend", CodeGenOpts<"ClearASTBeforeBackend">, + DefaultFalse, + PosFlag<SetTrue, [], "Clear">, + NegFlag<SetFalse, [], "Don't clear">, + BothFlags<[], " the Clang AST before running backend code generation">>; def enable_noundef_analysis : Flag<["-"], "enable-noundef-analysis">, Group<f_Group>, HelpText<"Enable analyzing function argument and return types for mandatory definedness">, MarshallingInfoFlag<CodeGenOpts<"EnableNoundefAttrs">>;
Index: clang/test/Misc/clear-ast-before-backend.c =================================================================== --- clang/test/Misc/clear-ast-before-backend.c +++ clang/test/Misc/clear-ast-before-backend.c @@ -1,9 +1,14 @@ -// RUN: %clang_cc1 -clear-ast-before-backend %s -emit-obj -o /dev/null -O1 -// RUN: %clang_cc1 -clear-ast-before-backend %s -emit-obj -o /dev/null -print-stats 2>&1 | FileCheck %s +// REQUIRES: asserts -// CHECK: *** Decl Stats: -// CHECK: {{.*}} decls total -// CHECK: 1 Function decls -// CHECK: Total bytes = +// RUN: %clang_cc1 -mllvm -debug-only=codegenaction -clear-ast-before-backend %s -emit-obj -o /dev/null -O1 2>&1 | FileCheck %s --check-prefix=YES +// RUN: %clang_cc1 -mllvm -debug-only=codegenaction -clear-ast-before-backend -no-clear-ast-before-backend %s -emit-obj -o /dev/null -O1 2>&1 | FileCheck %s --allow-empty --check-prefix=NO +// RUN: %clang_cc1 -clear-ast-before-backend %s -emit-obj -o /dev/null -print-stats 2>&1 | FileCheck %s --check-prefix=STATS + +// YES: Clearing AST +// NO-NOT: Clearing AST +// STATS: *** Decl Stats: +// STATS: {{.*}} decls total +// STATS: 1 Function decls +// STATS: Total bytes = void f() {} Index: clang/lib/CodeGen/CodeGenAction.cpp =================================================================== --- clang/lib/CodeGen/CodeGenAction.cpp +++ clang/lib/CodeGen/CodeGenAction.cpp @@ -52,6 +52,8 @@ using namespace clang; using namespace llvm; +#define DEBUG_TYPE "codegenaction" + namespace clang { class BackendConsumer; class ClangDiagnosticHandler final : public DiagnosticHandler { @@ -352,6 +354,7 @@ } if (CodeGenOpts.ClearASTBeforeBackend) { + LLVM_DEBUG(llvm::dbgs() << "Clearing AST...\n"); // Access to the AST is no longer available after this. // Other things that the ASTContext manages are still available, e.g. // the SourceManager. It'd be nice if we could separate out all the Index: clang/include/clang/Driver/Options.td =================================================================== --- clang/include/clang/Driver/Options.td +++ clang/include/clang/Driver/Options.td @@ -5311,9 +5311,11 @@ def disable_free : Flag<["-"], "disable-free">, HelpText<"Disable freeing of memory on exit">, MarshallingInfoFlag<FrontendOpts<"DisableFree">>; -def clear_ast_before_backend : Flag<["-"], "clear-ast-before-backend">, - HelpText<"Clear the Clang AST before running backend code generation">, - MarshallingInfoFlag<CodeGenOpts<"ClearASTBeforeBackend">>; +defm clear_ast_before_backend : BoolOption<"", "clear-ast-before-backend", CodeGenOpts<"ClearASTBeforeBackend">, + DefaultFalse, + PosFlag<SetTrue, [], "Clear">, + NegFlag<SetFalse, [], "Don't clear">, + BothFlags<[], " the Clang AST before running backend code generation">>; def enable_noundef_analysis : Flag<["-"], "enable-noundef-analysis">, Group<f_Group>, HelpText<"Enable analyzing function argument and return types for mandatory definedness">, MarshallingInfoFlag<CodeGenOpts<"EnableNoundefAttrs">>;
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits