Skip to content

Commit

Permalink
More prefixing of exposed macros
Browse files Browse the repository at this point in the history
  • Loading branch information
MikePopoloski committed May 2, 2023
1 parent c91c323 commit 3378842
Show file tree
Hide file tree
Showing 106 changed files with 706 additions and 706 deletions.
4 changes: 2 additions & 2 deletions .lcovrc
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ lcov_function_coverage = 1
# Specify if branch coverage data should be collected and processed.
lcov_branch_coverage = 0

# Add project-specific exclusions for the ASSUME_UNREACHABLE macro
# Add project-specific exclusions for the SLANG_UNREACHABLE macro
# since that branch is by design never reachable in real code,
# and for a 'default' case block that is empty since it's very
# irritating to see missed coverage on that line -- either the remaining
# block is also missed or it's an empty case and we don't care.
lcov_excl_line = LCOV_EXCL_LINE|ASSUME_UNREACHABLE|default:$
lcov_excl_line = LCOV_EXCL_LINE|SLANG_UNREACHABLE|default:$
2 changes: 1 addition & 1 deletion CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Coverage",
"CMAKE_CXX_COMPILER": "g++-12",
"CMAKE_CXX_FLAGS_COVERAGE": "-Og -g --coverage -DASSERT_ENABLED=0 -fno-omit-frame-pointer -fno-optimize-sibling-calls -fno-inline -fno-inline-small-functions -fno-default-inline",
"CMAKE_CXX_FLAGS_COVERAGE": "-Og -g --coverage -DSLANG_ASSERT_ENABLED=0 -fno-omit-frame-pointer -fno-optimize-sibling-calls -fno-inline -fno-inline-small-functions -fno-default-inline",
"CMAKE_EXE_LINKER_FLAGS_COVERAGE": "--coverage",
"CMAKE_SHARED_LINKER_FLAGS_COVERAGE": "--coverage",
"SLANG_INCLUDE_COVERAGE": "ON",
Expand Down
6 changes: 3 additions & 3 deletions docs/common-components.dox
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,14 @@ be null. Otherwise, any pointer (that's not in a dynamically sized list) must
be assumed to potentially be null.
- The @ref slang::ScopeGuard template makes it easy to have a function (typically
given via a lambda) that should run once the guard is destructed.
- The ASSERT macro does runtime checking of invariants. It should only be used
- The SLANG_ASSERT macro does runtime checking of invariants. It should only be used
to check things that should always be true if the programmer has not made any
mistakes. User errors must instead be handled gracefully.
- It's very common to have big switch statements that cover all expected
possibilities but need a default case to handle programmer bugs; in those cases,
you can use the ASSUME_UNREACHABLE macro which unconditionally throws a
you can use the SLANG_UNREACHABLE macro which unconditionally throws a
std::logic_error in debug builds and marks the path unreachable in release builds.
- The ENUM macro is used to define scoped enumerations that have a toString()
- The SLANG_ENUM macro is used to define scoped enumerations that have a toString()
method. Ideally C++ will expose this at the language level at some point but
until then we're on our own.
- The @ref slang::bitmask template wraps scoped enumerations that should be treated
Expand Down
2 changes: 1 addition & 1 deletion include/slang/ast/ASTContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ class SLANG_EXPORT ASTContext {
bitmask<ASTFlags> flags = ASTFlags::None) :
scope(&scope),
lookupIndex(lookupLocation.getIndex()), flags(flags) {
ASSERT(!lookupLocation.getScope() || lookupLocation.getScope() == &scope);
SLANG_ASSERT(!lookupLocation.getScope() || lookupLocation.getScope() == &scope);
}

Compilation& getCompilation() const { return scope->getCompilation(); }
Expand Down
18 changes: 9 additions & 9 deletions include/slang/ast/ASTVisitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ decltype(auto) Symbol::visit(TVisitor&& visitor, Args&&... args) const {
#undef TYPE
#undef SYMBOL
// clang-format on
ASSUME_UNREACHABLE;
SLANG_UNREACHABLE;
}

template<typename TVisitor, typename... Args>
Expand Down Expand Up @@ -267,7 +267,7 @@ decltype(auto) Statement::visit(TVisitor&& visitor, Args&&... args) const {
}
#undef CASE
// clang-format on
ASSUME_UNREACHABLE;
SLANG_UNREACHABLE;
}

template<typename TVisitor, typename... Args>
Expand All @@ -288,7 +288,7 @@ decltype(auto) TimingControl::visit(TVisitor& visitor, Args&&... args) const {
}
#undef CASE
// clang-format on
ASSUME_UNREACHABLE;
SLANG_UNREACHABLE;
}

template<typename TExpression, typename TVisitor, typename... Args>
Expand Down Expand Up @@ -344,7 +344,7 @@ decltype(auto) Expression::visitExpression(TExpression* expr, TVisitor&& visitor
}
#undef CASE
// clang-format on
ASSUME_UNREACHABLE;
SLANG_UNREACHABLE;
}

template<typename TVisitor, typename... Args>
Expand Down Expand Up @@ -382,7 +382,7 @@ decltype(auto) Constraint::visit(TVisitor& visitor, Args&&... args) const {
}
#undef CASE
// clang-format on
ASSUME_UNREACHABLE;
SLANG_UNREACHABLE;
}

template<typename TVisitor, typename... Args>
Expand All @@ -406,7 +406,7 @@ decltype(auto) AssertionExpr::visit(TVisitor& visitor, Args&&... args) const {
}
#undef CASE
// clang-format on
ASSUME_UNREACHABLE;
SLANG_UNREACHABLE;
}

template<typename TVisitor, typename... Args>
Expand All @@ -424,7 +424,7 @@ decltype(auto) BinsSelectExpr::visit(TVisitor& visitor, Args&&... args) const {
}
#undef CASE
// clang-format on
ASSUME_UNREACHABLE;
SLANG_UNREACHABLE;
}

template<typename TVisitor, typename... Args>
Expand All @@ -441,7 +441,7 @@ decltype(auto) Pattern::visit(TVisitor& visitor, Args&&... args) const {
}
#undef CASE
// clang-format on
ASSUME_UNREACHABLE;
SLANG_UNREACHABLE;
}

template<typename TVisitor, typename... Args>
Expand All @@ -457,7 +457,7 @@ decltype(auto) RandSeqProductionSymbol::ProdBase::visit(TVisitor& visitor, Args&
}
#undef CASE
// clang-format on
ASSUME_UNREACHABLE;
SLANG_UNREACHABLE;
}

/// @endcond
Expand Down
4 changes: 2 additions & 2 deletions include/slang/ast/Constraints.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,13 @@ class SLANG_EXPORT Constraint {

template<typename T>
T& as() {
ASSERT(T::isKind(kind));
SLANG_ASSERT(T::isKind(kind));
return *static_cast<T*>(this);
}

template<typename T>
const T& as() const {
ASSERT(T::isKind(kind));
SLANG_ASSERT(T::isKind(kind));
return *static_cast<const T*>(this);
}

Expand Down
4 changes: 2 additions & 2 deletions include/slang/ast/Expression.h
Original file line number Diff line number Diff line change
Expand Up @@ -309,13 +309,13 @@ class SLANG_EXPORT Expression {

template<typename T>
T& as() {
ASSERT(T::isKind(kind));
SLANG_ASSERT(T::isKind(kind));
return *static_cast<T*>(this);
}

template<typename T>
const T& as() const {
ASSERT(T::isKind(kind));
SLANG_ASSERT(T::isKind(kind));
return *static_cast<const T*>(this);
}

Expand Down
4 changes: 2 additions & 2 deletions include/slang/ast/Patterns.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,13 @@ class SLANG_EXPORT Pattern {

template<typename T>
T& as() {
ASSERT(T::isKind(kind));
SLANG_ASSERT(T::isKind(kind));
return *static_cast<T*>(this);
}

template<typename T>
const T& as() const {
ASSERT(T::isKind(kind));
SLANG_ASSERT(T::isKind(kind));
return *static_cast<const T*>(this);
}

Expand Down
4 changes: 2 additions & 2 deletions include/slang/ast/Scope.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class SLANG_EXPORT Scope {
template<typename T>
const T& find(std::string_view name) const {
const Symbol* sym = find(name);
ASSERT(sym);
SLANG_ASSERT(sym);
return sym->as<T>();
}

Expand All @@ -102,7 +102,7 @@ class SLANG_EXPORT Scope {
const T& lookupName(std::string_view name, LookupLocation location = LookupLocation::max,
bitmask<LookupFlags> flags = LookupFlags::None) const {
const Symbol* sym = lookupName(name, location, flags);
ASSERT(sym);
SLANG_ASSERT(sym);
return sym->as<T>();
}

Expand Down
4 changes: 2 additions & 2 deletions include/slang/ast/Statements.h
Original file line number Diff line number Diff line change
Expand Up @@ -209,13 +209,13 @@ class SLANG_EXPORT Statement {

template<typename T>
T& as() {
ASSERT(T::isKind(kind));
SLANG_ASSERT(T::isKind(kind));
return *static_cast<T*>(this);
}

template<typename T>
const T& as() const {
ASSERT(T::isKind(kind));
SLANG_ASSERT(T::isKind(kind));
return *static_cast<const T*>(this);
}

Expand Down
4 changes: 2 additions & 2 deletions include/slang/ast/Symbol.h
Original file line number Diff line number Diff line change
Expand Up @@ -195,11 +195,11 @@ class SLANG_EXPORT Symbol {
decltype(auto) as() {
if constexpr (std::is_same_v<T, Scope>) {
const Scope* scope = scopeOrNull();
ASSERT(scope);
SLANG_ASSERT(scope);
return *scope;
}
else {
ASSERT(T::isKind(kind));
SLANG_ASSERT(T::isKind(kind));
return *static_cast<T*>(this);
}
}
Expand Down
2 changes: 1 addition & 1 deletion include/slang/ast/SystemSubroutine.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class SLANG_EXPORT SimpleSystemSubroutine : public SystemSubroutine {
SystemSubroutine(name, kind),
argTypes(argTypes), returnType(&returnType), requiredArgs(requiredArgs), isMethod(isMethod),
isFirstArgLValue(isFirstArgLValue) {
ASSERT(requiredArgs <= argTypes.size());
SLANG_ASSERT(requiredArgs <= argTypes.size());
}

private:
Expand Down
4 changes: 2 additions & 2 deletions include/slang/ast/TimingControl.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,13 @@ class SLANG_EXPORT TimingControl {

template<typename T>
T& as() {
ASSERT(T::isKind(kind));
SLANG_ASSERT(T::isKind(kind));
return *static_cast<T*>(this);
}

template<typename T>
const T& as() const {
ASSERT(T::isKind(kind));
SLANG_ASSERT(T::isKind(kind));
return *static_cast<const T*>(this);
}

Expand Down
4 changes: 2 additions & 2 deletions include/slang/ast/expressions/AssertionExpr.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,13 @@ class SLANG_EXPORT AssertionExpr {

template<typename T>
T& as() {
ASSERT(T::isKind(kind));
SLANG_ASSERT(T::isKind(kind));
return *static_cast<T*>(this);
}

template<typename T>
const T& as() const {
ASSERT(T::isKind(kind));
SLANG_ASSERT(T::isKind(kind));
return *static_cast<const T*>(this);
}

Expand Down
2 changes: 1 addition & 1 deletion include/slang/ast/expressions/MiscExpressions.h
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ class SLANG_EXPORT AssertionInstanceExpression : public Expression {
body.visit(visitor);
for (auto sym : localVars) {
auto dt = sym->getDeclaredType();
ASSERT(dt);
SLANG_ASSERT(dt);
if (auto init = dt->getInitializer())
init->visit(visitor);
}
Expand Down
6 changes: 3 additions & 3 deletions include/slang/ast/symbols/CoverSymbols.h
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ class SLANG_EXPORT CoverpointSymbol : public Symbol, public Scope {

const Expression& getCoverageExpr() const {
auto init = declaredType.getInitializer();
ASSERT(init);
SLANG_ASSERT(init);
return *init;
}

Expand Down Expand Up @@ -264,13 +264,13 @@ class SLANG_EXPORT BinsSelectExpr {

template<typename T>
T& as() {
ASSERT(T::isKind(kind));
SLANG_ASSERT(T::isKind(kind));
return *static_cast<T*>(this);
}

template<typename T>
const T& as() const {
ASSERT(T::isKind(kind));
SLANG_ASSERT(T::isKind(kind));
return *static_cast<const T*>(this);
}

Expand Down
6 changes: 3 additions & 3 deletions include/slang/ast/symbols/MemberSymbols.h
Original file line number Diff line number Diff line change
Expand Up @@ -393,13 +393,13 @@ class SLANG_EXPORT RandSeqProductionSymbol : public Symbol, public Scope {

template<typename T>
T& as() {
ASSERT(T::isKind(kind));
SLANG_ASSERT(T::isKind(kind));
return *static_cast<T*>(this);
}

template<typename T>
const T& as() const {
ASSERT(T::isKind(kind));
SLANG_ASSERT(T::isKind(kind));
return *static_cast<const T*>(this);
}

Expand Down Expand Up @@ -562,7 +562,7 @@ class SLANG_EXPORT RandSeqProductionSymbol : public Symbol, public Scope {
break;
}
default:
ASSUME_UNREACHABLE;
SLANG_UNREACHABLE;
}
}

Expand Down
6 changes: 3 additions & 3 deletions include/slang/ast/types/DeclaredType.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ class SLANG_EXPORT DeclaredType {
/// Sets the source syntax for the type, which will later be used when
/// resolution is requested.
void setTypeSyntax(const syntax::DataTypeSyntax& newType) {
ASSERT(!type);
SLANG_ASSERT(!type);
typeOrLink.typeSyntax = &newType;
hasLink = false;
}
Expand Down Expand Up @@ -158,7 +158,7 @@ class SLANG_EXPORT DeclaredType {
/// @param syntax The initializer expression syntax.
/// @param loc The source location to use when reporting diagnostics about the initializer.
void setInitializerSyntax(const syntax::ExpressionSyntax& syntax, SourceLocation loc) {
ASSERT(!initializer);
SLANG_ASSERT(!initializer);
initializerSyntax = &syntax;
initializerLocation = loc;
}
Expand Down Expand Up @@ -187,7 +187,7 @@ class SLANG_EXPORT DeclaredType {
/// This will clear any resolved type to force resolution again with the
/// new flags set.
void addFlags(bitmask<DeclaredTypeFlags> toAdd) {
ASSERT(!type && !initializer);
SLANG_ASSERT(!type && !initializer);
flags |= toAdd;
}

Expand Down
4 changes: 2 additions & 2 deletions include/slang/numeric/SVInt.h
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ class SLANG_EXPORT SVInt : SVIntStorage {
/// Construct from a 64-bit value that can be given an arbitrarily large number of bits (sign
/// extended if necessary).
SVInt(bitwidth_t bits, uint64_t value, bool isSigned) : SVIntStorage(bits, isSigned, false) {
ASSERT(bits > 0 && bits <= MAX_BITS);
SLANG_ASSERT(bits > 0 && bits <= MAX_BITS);
if (isSingleWord())
val = value;
else
Expand All @@ -206,7 +206,7 @@ class SLANG_EXPORT SVInt : SVIntStorage {
/// Construct from numeric data already in memory as a range of bytes.
SVInt(bitwidth_t bits, std::span<const byte> bytes, bool isSigned) :
SVIntStorage(bits, isSigned, false) {
ASSERT(bits > 0 && bits <= MAX_BITS);
SLANG_ASSERT(bits > 0 && bits <= MAX_BITS);
initSlowCase(bytes);
}

Expand Down
2 changes: 1 addition & 1 deletion include/slang/parsing/NumberParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ class NumberParser {
<< real_t(std::numeric_limits<double>::denorm_min());
}
else {
ASSERT(!std::isfinite(literal.realValue()));
SLANG_ASSERT(!std::isfinite(literal.realValue()));
addDiag(diag::RealLiteralOverflow, literal.location())
<< real_t(std::numeric_limits<double>::max());
}
Expand Down
Loading

0 comments on commit 3378842

Please sign in to comment.