Author: Davide Cunial Date: 2026-01-19T10:07:52Z New Revision: 58027ec087f49c6a26458e63832e62642882415b
URL: https://github.com/llvm/llvm-project/commit/58027ec087f49c6a26458e63832e62642882415b DIFF: https://github.com/llvm/llvm-project/commit/58027ec087f49c6a26458e63832e62642882415b.diff LOG: [clang] Fix options handling in ClangExtDefMapGen.cpp (#176116) Also, remove some unused includes. Fixes https://github.com/llvm/llvm-project/issues/176118 Now, running `clang-extdef-mapping` with no options results in the following error message: ```sh error: clang-extdef-mapping: Not enough positional command line arguments specified! Must specify at least 1 positional argument: See: ./build/Debug/bin/clang-extdef-mapping --help ``` (cherry picked from commit 0a26d907ceec0a64596d334848fa7ec8b163a59e) Added: clang/test/Tooling/clang-extdef-mapping-no-args.cpp clang/test/Tooling/clang-extdef-mapping.cpp Modified: clang/tools/clang-extdef-mapping/ClangExtDefMapGen.cpp Removed: ################################################################################ diff --git a/clang/test/Tooling/clang-extdef-mapping-no-args.cpp b/clang/test/Tooling/clang-extdef-mapping-no-args.cpp new file mode 100644 index 0000000000000..751faa5488613 --- /dev/null +++ b/clang/test/Tooling/clang-extdef-mapping-no-args.cpp @@ -0,0 +1,3 @@ +// RUN: not clang-extdef-mapping 2>&1 | FileCheck %s + +// CHECK: Not enough positional command line arguments specified! diff --git a/clang/test/Tooling/clang-extdef-mapping.cpp b/clang/test/Tooling/clang-extdef-mapping.cpp new file mode 100644 index 0000000000000..31756e3bd6237 --- /dev/null +++ b/clang/test/Tooling/clang-extdef-mapping.cpp @@ -0,0 +1,4 @@ +// RUN: clang-extdef-mapping "%s" 2>&1 | FileCheck %s + +// CHECK: 8:c:@F@foo {{.*}}clang-extdef-mapping.cpp +extern "C" int foo() { return 0; } diff --git a/clang/tools/clang-extdef-mapping/ClangExtDefMapGen.cpp b/clang/tools/clang-extdef-mapping/ClangExtDefMapGen.cpp index 6d8f86b13fa36..308a421f964a9 100644 --- a/clang/tools/clang-extdef-mapping/ClangExtDefMapGen.cpp +++ b/clang/tools/clang-extdef-mapping/ClangExtDefMapGen.cpp @@ -17,15 +17,14 @@ #include "clang/Basic/SourceManager.h" #include "clang/CrossTU/CrossTranslationUnit.h" #include "clang/Frontend/CompilerInstance.h" -#include "clang/Frontend/FrontendActions.h" #include "clang/Frontend/TextDiagnosticPrinter.h" #include "clang/Tooling/CommonOptionsParser.h" #include "clang/Tooling/Tooling.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/Signals.h" #include "llvm/Support/TargetSelect.h" +#include "llvm/Support/WithColor.h" #include <optional> -#include <sstream> #include <string> using namespace llvm; @@ -211,9 +210,9 @@ int main(int argc, const char **argv) { "with compile database or .ast files that are " "created from clang's -emit-ast option.\n"; auto ExpectedParser = CommonOptionsParser::create( - argc, argv, ClangExtDefMapGenCategory, cl::ZeroOrMore, Overview); + argc, argv, ClangExtDefMapGenCategory, cl::OneOrMore, Overview); if (!ExpectedParser) { - llvm::errs() << ExpectedParser.takeError(); + llvm::WithColor::error() << llvm::toString(ExpectedParser.takeError()); return 1; } CommonOptionsParser &OptionsParser = ExpectedParser.get(); _______________________________________________ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
