Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:42:49

0001 //===-- CommandAlias.h -----------------------------------------*- C++ -*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 
0009 #ifndef LLDB_INTERPRETER_COMMANDALIAS_H
0010 #define LLDB_INTERPRETER_COMMANDALIAS_H
0011 
0012 #include <memory>
0013 
0014 #include "lldb/Interpreter/CommandObject.h"
0015 #include "lldb/Utility/Args.h"
0016 #include "lldb/Utility/CompletionRequest.h"
0017 #include "lldb/lldb-forward.h"
0018 
0019 namespace lldb_private {
0020 class CommandAlias : public CommandObject {
0021 public:
0022   typedef std::unique_ptr<CommandAlias> UniquePointer;
0023 
0024   CommandAlias(CommandInterpreter &interpreter, lldb::CommandObjectSP cmd_sp,
0025                llvm::StringRef options_args, llvm::StringRef name,
0026                llvm::StringRef help = llvm::StringRef(),
0027                llvm::StringRef syntax = llvm::StringRef(), uint32_t flags = 0);
0028 
0029   void GetAliasExpansion(StreamString &help_string) const;
0030 
0031   bool IsValid() const { return m_underlying_command_sp && m_option_args_sp; }
0032 
0033   explicit operator bool() const { return IsValid(); }
0034 
0035   bool WantsRawCommandString() override;
0036 
0037   bool WantsCompletion() override;
0038 
0039   void HandleCompletion(CompletionRequest &request) override;
0040 
0041   void
0042   HandleArgumentCompletion(CompletionRequest &request,
0043                            OptionElementVector &opt_element_vector) override;
0044 
0045   Options *GetOptions() override;
0046 
0047   bool IsAlias() override { return true; }
0048 
0049   bool IsDashDashCommand() override;
0050 
0051   llvm::StringRef GetHelp() override;
0052 
0053   llvm::StringRef GetHelpLong() override;
0054 
0055   void SetHelp(llvm::StringRef str) override;
0056 
0057   void SetHelpLong(llvm::StringRef str) override;
0058 
0059   void Execute(const char *args_string, CommandReturnObject &result) override;
0060 
0061   lldb::CommandObjectSP GetUnderlyingCommand() {
0062     return m_underlying_command_sp;
0063   }
0064   OptionArgVectorSP GetOptionArguments() const { return m_option_args_sp; }
0065   const char *GetOptionString() { return m_option_string.c_str(); }
0066 
0067   // this takes an alias - potentially nested (i.e. an alias to an alias) and
0068   // expands it all the way to a non-alias command
0069   std::pair<lldb::CommandObjectSP, OptionArgVectorSP> Desugar();
0070 
0071 protected:
0072   bool IsNestedAlias();
0073 
0074 private:
0075   lldb::CommandObjectSP m_underlying_command_sp;
0076   std::string m_option_string;
0077   OptionArgVectorSP m_option_args_sp;
0078   LazyBool m_is_dashdash_alias;
0079   bool m_did_set_help : 1;
0080   bool m_did_set_help_long : 1;
0081 };
0082 } // namespace lldb_private
0083 
0084 #endif // LLDB_INTERPRETER_COMMANDALIAS_H