Internals: Add VL_MT_SAFE annotations to const functions (#3681)

This commit is contained in:
Kamil Rakoczy
2022-10-18 17:07:09 -04:00
committed by GitHub
parent 54e3f15dce
commit b6c116d4bf
23 changed files with 380 additions and 342 deletions
+9 -9
View File
@@ -155,7 +155,7 @@ void VFileContent::pushText(const string& text) {
m_lines.emplace_back(string(leftover, line_start)); // Might be ""
}
string VFileContent::getLine(int lineno) const {
string VFileContent::getLine(int lineno) const VL_MT_SAFE {
// Return error text rather than asserting so the user isn't left without a message
// cppcheck-suppress negativeContainerIndex
if (VL_UNCOVERABLE(lineno < 0 || lineno >= (int)m_lines.size())) {
@@ -284,7 +284,7 @@ FileLine* FileLine::copyOrSameFileLine() {
return newp;
}
string FileLine::filebasename() const {
string FileLine::filebasename() const VL_MT_SAFE {
string name = filename();
string::size_type pos;
if ((pos = name.rfind('/')) != string::npos) name.erase(0, pos + 1);
@@ -298,7 +298,7 @@ string FileLine::filebasenameNoExt() const {
return name;
}
string FileLine::firstColumnLetters() const {
string FileLine::firstColumnLetters() const VL_MT_SAFE {
const char a = ((firstColumn() / 26) % 26) + 'a';
const char b = (firstColumn() % 26) + 'a';
return string(1, a) + string(1, b);
@@ -322,7 +322,7 @@ string FileLine::asciiLineCol() const {
+ "-" + cvtToStr(lastColumn()) + "[" + (m_contentp ? m_contentp->ascii() : "ct0") + "+"
+ cvtToStr(m_contentLineno) + "]");
}
string FileLine::ascii() const {
string FileLine::ascii() const VL_MT_SAFE {
// For most errors especially in the parser the lastLineno is more accurate than firstLineno
return filename() + ":" + cvtToStr(lastLineno()) + ":" + cvtToStr(firstColumn());
}
@@ -369,7 +369,7 @@ void FileLine::warnUnusedOff(bool flag) {
warnOff(V3ErrorCode::UNUSEDSIGNAL, flag);
}
bool FileLine::warnIsOff(V3ErrorCode code) const {
bool FileLine::warnIsOff(V3ErrorCode code) const VL_MT_SAFE {
if (!msgEn().test(code)) return true;
if (!defaultFileLine().msgEn().test(code)) return true; // Global overrides local
if ((code.lintError() || code.styleError()) && !msgEn().test(V3ErrorCode::I_LINT)) {
@@ -406,7 +406,7 @@ string FileLine::warnMore() const {
return V3Error::warnMore();
}
}
string FileLine::warnOther() const {
string FileLine::warnOther() const VL_MT_SAFE {
if (lastLineno()) {
return V3Error::warnMore() + ascii() + ": ";
} else {
@@ -414,7 +414,7 @@ string FileLine::warnOther() const {
}
}
string FileLine::source() const {
string FileLine::source() const VL_MT_SAFE {
if (VL_UNCOVERABLE(!m_contentp)) { // LCOV_EXCL_START
if (debug() || v3Global.opt.debugCheck()) {
// The newline here is to work around the " <line#> | "
@@ -425,7 +425,7 @@ string FileLine::source() const {
} // LCOV_EXCL_STOP
return m_contentp->getLine(m_contentLineno);
}
string FileLine::prettySource() const {
string FileLine::prettySource() const VL_MT_SAFE {
string out = source();
// Drop ignore trailing newline
const string::size_type pos = out.find('\n');
@@ -434,7 +434,7 @@ string FileLine::prettySource() const {
return VString::spaceUnprintable(out);
}
string FileLine::warnContext(bool secondary) const {
string FileLine::warnContext(bool secondary) const VL_MT_SAFE {
V3Error::errorContexted(true);
if (!v3Global.opt.context()) return "";
string out;