A lot of comments in LLDB are surrounded by an ASCII line to delimit the begging and end of the comment. Its use is not really consistent across the code base, sometimes the lines are longer, sometimes they are shorter and sometimes they are omitted. Furthermore, it looks kind of weird with the 80 column limit, where the comment actually extends past the line, but not by much. Furthermore, when /// is used for Doxygen comments, it looks particularly odd. And when // is used, it incorrectly gives the impression that it's actually a Doxygen comment. I assume these lines were added to improve distinguishing between comments and code. However, given that todays editors and IDEs do a great job at highlighting comments, I think it's worth to drop this for the sake of consistency. The alternative is fixing all the inconsistencies, which would create a lot more churn. Differential revision: https://reviews.llvm.org/D60508 llvm-svn: 358135
124 lines
3.4 KiB
C++
124 lines
3.4 KiB
C++
//===-- MICmnBase.cpp -------------------------------------------*- C++ -*-===//
|
|
//
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Third party headers
|
|
#include <stdarg.h>
|
|
|
|
// In-house headers:
|
|
#include "MICmnBase.h"
|
|
#include "MICmnLog.h"
|
|
#include "MICmnStreamStderr.h"
|
|
|
|
//++
|
|
// Details: CMICmnBase constructor.
|
|
// Type: Method.
|
|
// Args: None.
|
|
// Return: None.
|
|
// Throws: None.
|
|
//--
|
|
CMICmnBase::CMICmnBase()
|
|
: m_strMILastErrorDescription(CMIUtilString()), m_bInitialized(false),
|
|
m_pLog(&CMICmnLog::Instance()), m_clientUsageRefCnt(0) {}
|
|
|
|
//++
|
|
// Details: CMICmnBase destructor.
|
|
// Type: Overrideable.
|
|
// Args: None.
|
|
// Return: None.
|
|
// Throws: None.
|
|
//--
|
|
CMICmnBase::~CMICmnBase() { m_pLog = NULL; }
|
|
|
|
//++
|
|
// Details: Retrieve whether *this object has an error description set.
|
|
// Type: Method.
|
|
// Args: None.
|
|
// Return: bool - True = Yes already defined, false = empty description.
|
|
// Throws: None.
|
|
//--
|
|
bool CMICmnBase::HaveErrorDescription() const {
|
|
return m_strMILastErrorDescription.empty();
|
|
}
|
|
|
|
//++
|
|
// Details: Retrieve MI's last error condition.
|
|
// Type: Method.
|
|
// Args: None.
|
|
// Return: CMIUtilString & - Text description.
|
|
// Throws: None.
|
|
//--
|
|
const CMIUtilString &CMICmnBase::GetErrorDescription() const {
|
|
return m_strMILastErrorDescription;
|
|
}
|
|
|
|
//++
|
|
// Details: Set MI's error condition description. This may be accessed by
|
|
// clients and
|
|
// seen by users. Message is available to the client using the server
|
|
// and sent
|
|
// to the Logger.
|
|
// Type: Method.
|
|
// Args: vrTxt - (R) Text description.
|
|
// Return: None.
|
|
// Throws: None.
|
|
//--
|
|
void CMICmnBase::SetErrorDescription(const CMIUtilString &vrTxt) const {
|
|
m_strMILastErrorDescription = vrTxt;
|
|
if (!vrTxt.empty()) {
|
|
const CMIUtilString txt(CMIUtilString::Format("Error: %s", vrTxt.c_str()));
|
|
CMICmnStreamStderr::Instance().Write(txt);
|
|
}
|
|
}
|
|
|
|
//++
|
|
// Details: Set MI's error condition description. This may be accessed by
|
|
// clients and
|
|
// seen by users. Message is available to the client using the server
|
|
// and sent
|
|
// to the Logger.
|
|
// Type: Method.
|
|
// Args: vrTxt - (R) Text description.
|
|
// Return: None.
|
|
// Throws: None.
|
|
//--
|
|
void CMICmnBase::SetErrorDescriptionNoLog(const CMIUtilString &vrTxt) const {
|
|
m_strMILastErrorDescription = vrTxt;
|
|
}
|
|
|
|
//++
|
|
// Details: Clear MI's error condition description.
|
|
// Type: Method.
|
|
// Args: None.
|
|
// Return: None.
|
|
// Throws: None.
|
|
//--
|
|
void CMICmnBase::ClrErrorDescription() const {
|
|
m_strMILastErrorDescription.clear();
|
|
}
|
|
|
|
//++
|
|
// Details: Set MI's error condition description. This may be accessed by
|
|
// clients and
|
|
// seen by users. Message is available to the client using the server
|
|
// and sent
|
|
// to the Logger.
|
|
// Type: Method.
|
|
// Args: vFormat - (R) Format string.
|
|
// ... - (R) Variable number of CMIUtilString type objects.
|
|
// Return: None.
|
|
// Throws: None.
|
|
//--
|
|
void CMICmnBase::SetErrorDescriptionn(const char *vFormat, ...) const {
|
|
va_list args;
|
|
va_start(args, vFormat);
|
|
CMIUtilString strResult = CMIUtilString::FormatValist(vFormat, args);
|
|
va_end(args);
|
|
|
|
SetErrorDescription(strResult);
|
|
}
|