teak-llvm/lldb/source/Core/UserSettingsController.cpp
Kate Stone b9c1b51e45 *** This commit represents a complete reformatting of the LLDB source code
*** to conform to clang-format’s LLVM style.  This kind of mass change has
*** two obvious implications:

Firstly, merging this particular commit into a downstream fork may be a huge
effort.  Alternatively, it may be worth merging all changes up to this commit,
performing the same reformatting operation locally, and then discarding the
merge for this particular commit.  The commands used to accomplish this
reformatting were as follows (with current working directory as the root of
the repository):

    find . \( -iname "*.c" -or -iname "*.cpp" -or -iname "*.h" -or -iname "*.mm" \) -exec clang-format -i {} +
    find . -iname "*.py" -exec autopep8 --in-place --aggressive --aggressive {} + ;

The version of clang-format used was 3.9.0, and autopep8 was 1.2.4.

Secondly, “blame” style tools will generally point to this commit instead of
a meaningful prior commit.  There are alternatives available that will attempt
to look through this change and find the appropriate prior commit.  YMMV.

llvm-svn: 280751
2016-09-06 20:57:50 +00:00

109 lines
3.7 KiB
C++

//====-- UserSettingsController.cpp ------------------------------*- C++
//-*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include <algorithm>
#include <string.h>
#include "lldb/Core/Error.h"
#include "lldb/Core/RegularExpression.h"
#include "lldb/Core/Stream.h"
#include "lldb/Core/StreamString.h"
#include "lldb/Core/UserSettingsController.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/OptionValueProperties.h"
#include "lldb/Interpreter/OptionValueString.h"
using namespace lldb;
using namespace lldb_private;
lldb::OptionValueSP
Properties::GetPropertyValue(const ExecutionContext *exe_ctx, const char *path,
bool will_modify, Error &error) const {
OptionValuePropertiesSP properties_sp(GetValueProperties());
if (properties_sp)
return properties_sp->GetSubValue(exe_ctx, path, will_modify, error);
return lldb::OptionValueSP();
}
Error Properties::SetPropertyValue(const ExecutionContext *exe_ctx,
VarSetOperationType op, const char *path,
const char *value) {
OptionValuePropertiesSP properties_sp(GetValueProperties());
if (properties_sp)
return properties_sp->SetSubValue(exe_ctx, op, path, value);
Error error;
error.SetErrorString("no properties");
return error;
}
void Properties::DumpAllPropertyValues(const ExecutionContext *exe_ctx,
Stream &strm, uint32_t dump_mask) {
OptionValuePropertiesSP properties_sp(GetValueProperties());
if (properties_sp)
return properties_sp->DumpValue(exe_ctx, strm, dump_mask);
}
void Properties::DumpAllDescriptions(CommandInterpreter &interpreter,
Stream &strm) const {
strm.PutCString("Top level variables:\n\n");
OptionValuePropertiesSP properties_sp(GetValueProperties());
if (properties_sp)
return properties_sp->DumpAllDescriptions(interpreter, strm);
}
Error Properties::DumpPropertyValue(const ExecutionContext *exe_ctx,
Stream &strm, const char *property_path,
uint32_t dump_mask) {
OptionValuePropertiesSP properties_sp(GetValueProperties());
if (properties_sp) {
return properties_sp->DumpPropertyValue(exe_ctx, strm, property_path,
dump_mask);
}
Error error;
error.SetErrorString("empty property list");
return error;
}
size_t
Properties::Apropos(const char *keyword,
std::vector<const Property *> &matching_properties) const {
OptionValuePropertiesSP properties_sp(GetValueProperties());
if (properties_sp) {
properties_sp->Apropos(keyword, matching_properties);
}
return matching_properties.size();
}
lldb::OptionValuePropertiesSP
Properties::GetSubProperty(const ExecutionContext *exe_ctx,
const ConstString &name) {
OptionValuePropertiesSP properties_sp(GetValueProperties());
if (properties_sp)
return properties_sp->GetSubProperty(exe_ctx, name);
return lldb::OptionValuePropertiesSP();
}
const char *Properties::GetExperimentalSettingsName() { return "experimental"; }
bool Properties::IsSettingExperimental(const char *setting) {
if (setting == nullptr)
return false;
const char *experimental = GetExperimentalSettingsName();
const char *dot_pos = strchr(setting, '.');
if (dot_pos == nullptr)
return strcmp(experimental, setting) == 0;
else {
size_t first_elem_len = dot_pos - setting;
return strncmp(experimental, setting, first_elem_len) == 0;
}
}