• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

rieske / trans / 28379938466

29 Jun 2026 02:35PM UTC coverage: 90.44% (-0.2%) from 90.635%
28379938466

push

github

web-flow
Merge pull request #41 from rieske/feature/file-scope-globals

Add file-scope global variables

300 of 358 new or added lines in 19 files covered. (83.8%)

8 existing lines in 2 files now uncovered.

5052 of 5586 relevant lines covered (90.44%)

242657.94 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

64.86
/src/ast/ConstantExpression.cpp
1
#include "ConstantExpression.h"
2

3
#include "AbstractSyntaxTreeVisitor.h"
4

5
namespace ast {
6

7
namespace {
8

9
// Decode an integer literal or a single-character constant ('a', '\n') to its value.
10
bool parseConstantToken(const std::string& token, long& value) {
52✔
11
    if (token.size() >= 3 && token.front() == '\'' && token.back() == '\'') {
52✔
12
        const std::string inner = token.substr(1, token.size() - 2);
2✔
13
        if (inner.size() == 1) {
2✔
14
            value = static_cast<unsigned char>(inner[0]);
2✔
15
            return true;
2✔
16
        }
NEW
17
        if (inner.size() == 2 && inner[0] == '\\') {
×
NEW
18
            switch (inner[1]) {
×
NEW
19
                case 'n': value = '\n'; return true;
×
NEW
20
                case 't': value = '\t'; return true;
×
NEW
21
                case 'r': value = '\r'; return true;
×
NEW
22
                case '0': value = '\0'; return true;
×
NEW
23
                case '\\': value = '\\'; return true;
×
NEW
24
                case '\'': value = '\''; return true;
×
NEW
25
                case '"': value = '"'; return true;
×
26
            }
27
        }
NEW
28
        return false;
×
29
    }
2✔
30
    try {
31
        // base 0: honor C's 0-prefix octal and 0x hex, else decimal.
32
        value = std::stol(token, nullptr, 0);
50✔
33
        return true;
50✔
NEW
34
    } catch (...) {
×
NEW
35
        return false;
×
NEW
36
    }
×
37
}
38

39
} // namespace
40

41
ConstantExpression::ConstantExpression(Constant constant) :
1,194✔
42
        constant { constant }
1,194✔
43
{
44
    setType(constant.getType());
1,194✔
45
}
1,194✔
46

47
ConstantExpression::~ConstantExpression() {
2,388✔
48
}
2,388✔
49

50
void ConstantExpression::accept(AbstractSyntaxTreeVisitor& visitor) {
3,496✔
51
    visitor.visit(*this);
3,496✔
52
}
3,496✔
53

54
translation_unit::Context ConstantExpression::getContext() const {
122✔
55
    return constant.getContext();
122✔
56
}
57

58
std::string ConstantExpression::getValue() const {
2,306✔
59
    return constant.getValue();
2,306✔
60
}
61

62
bool ConstantExpression::evaluateConstant(long& value) const {
52✔
63
    return parseConstantToken(constant.getValue(), value);
52✔
64
}
65

66
} // namespace ast
67

STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc