Merge pull request #67 from lioncash/class

Global: Make SeekOrigin an enum class
This commit is contained in:
Phillip Stephens 2019-09-14 08:37:58 -07:00 committed by GitHub
commit c28f77f75e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 4 deletions

View File

@ -629,7 +629,7 @@ class ATDNAEmitVisitor : public clang::RecursiveASTVisitor<ATDNAEmitVisitor> {
} else if (!tsDecl->getName().compare("Seek")) { } else if (!tsDecl->getName().compare("Seek")) {
size_t idx = 0; size_t idx = 0;
std::string offsetExprStr; std::string offsetExprStr;
llvm::APSInt direction(64, 0); llvm::APSInt direction(64, false);
const clang::Expr* directionExpr = nullptr; const clang::Expr* directionExpr = nullptr;
bool bad = false; bool bad = false;
for (const clang::TemplateArgument& arg : *tsType) { for (const clang::TemplateArgument& arg : *tsType) {
@ -649,8 +649,11 @@ class ATDNAEmitVisitor : public clang::RecursiveASTVisitor<ATDNAEmitVisitor> {
offsetExprStr = offsetLiteral.toString(10); offsetExprStr = offsetLiteral.toString(10);
} }
} else { } else {
clang::APValue result;
if (expr->isCXX11ConstantExpr(context, &result)) {
directionExpr = expr; directionExpr = expr;
if (!expr->isIntegerConstantExpr(direction, context)) { direction = result.getInt();
} else {
clang::DiagnosticBuilder diag = context.getDiagnostics().Report(expr->getExprLoc(), AthenaError); clang::DiagnosticBuilder diag = context.getDiagnostics().Report(expr->getExprLoc(), AthenaError);
diag.AddString("Unable to use non-constant direction expression in Athena"); diag.AddString("Unable to use non-constant direction expression in Athena");
diag.AddSourceRange(clang::CharSourceRange(expr->getSourceRange(), true)); diag.AddSourceRange(clang::CharSourceRange(expr->getSourceRange(), true));

View File

@ -123,7 +123,7 @@ namespace athena {
namespace error { namespace error {
enum class Level { Message, Warning, Error, Fatal }; enum class Level { Message, Warning, Error, Fatal };
} }
enum SeekOrigin { Begin, Current, End }; enum class SeekOrigin { Begin, Current, End };
enum Endian { Little, Big }; enum Endian { Little, Big };