diagnostic duplicates no longer raised

This commit is contained in:
Jack Andersen 2015-06-19 08:25:08 -10:00
parent fd3db3e1db
commit 242a06915b
3 changed files with 145 additions and 93 deletions

View File

@ -1,7 +1,7 @@
# PKGBUILD for libAthena # PKGBUILD for libAthena
_pkgname=libathena _pkgname=libathena
pkgname=$_pkgname-git pkgname=$_pkgname-git
pkgver=1.1.0.34.g7b1b027 pkgver=1.1.0.35.gfd3db3e
pkgrel=1 pkgrel=1
pkgdesc="Basic cross platform IO library" pkgdesc="Basic cross platform IO library"
arch=('i686' 'x86_64') arch=('i686' 'x86_64')

View File

@ -1,7 +1,7 @@
# PKGBUILD for atdna # PKGBUILD for atdna
_pkgname=atdna _pkgname=atdna
pkgname=$_pkgname-git pkgname=$_pkgname-git
pkgver=1.1.0.32.g1aa3a70 pkgver=1.1.0.35.gfd3db3e
pkgrel=1 pkgrel=1
pkgdesc="Companion DNA utility for libAthena" pkgdesc="Companion DNA utility for libAthena"
arch=('i686' 'x86_64') arch=('i686' 'x86_64')

View File

@ -279,9 +279,12 @@ public:
endianExpr = defArg; endianExpr = defArg;
if (!defArg->isIntegerConstantExpr(endian, context)) if (!defArg->isIntegerConstantExpr(endian, context))
{ {
clang::DiagnosticBuilder diag = context.getDiagnostics().Report(defArg->getLocStart(), AthenaError); if (!p)
diag.AddString("Endian value must be 'BigEndian' or 'LittleEndian'"); {
diag.AddSourceRange(clang::CharSourceRange(defArg->getSourceRange(), true)); clang::DiagnosticBuilder diag = context.getDiagnostics().Report(defArg->getLocStart(), AthenaError);
diag.AddString("Endian value must be 'BigEndian' or 'LittleEndian'");
diag.AddSourceRange(clang::CharSourceRange(defArg->getSourceRange(), true));
}
continue; continue;
} }
} }
@ -306,9 +309,12 @@ public:
endianExpr = expr; endianExpr = expr;
if (expr->isIntegerConstantExpr(endian, context)) if (expr->isIntegerConstantExpr(endian, context))
{ {
clang::DiagnosticBuilder diag = context.getDiagnostics().Report(expr->getLocStart(), AthenaError); if (!p)
diag.AddString("Endian value must be 'BigEndian' or 'LittleEndian'"); {
diag.AddSourceRange(clang::CharSourceRange(expr->getSourceRange(), true)); clang::DiagnosticBuilder diag = context.getDiagnostics().Report(expr->getLocStart(), AthenaError);
diag.AddString("Endian value must be 'BigEndian' or 'LittleEndian'");
diag.AddSourceRange(clang::CharSourceRange(expr->getSourceRange(), true));
}
continue; continue;
} }
} }
@ -317,26 +323,32 @@ public:
int endianVal = endian.getSExtValue(); int endianVal = endian.getSExtValue();
if (endianVal != 0 && endianVal != 1) if (endianVal != 0 && endianVal != 1)
{ {
if (endianExpr) if (!p)
{ {
clang::DiagnosticBuilder diag = context.getDiagnostics().Report(endianExpr->getLocStart(), AthenaError); if (endianExpr)
diag.AddString("Endian value must be 'BigEndian' or 'LittleEndian'"); {
diag.AddSourceRange(clang::CharSourceRange(endianExpr->getSourceRange(), true)); clang::DiagnosticBuilder diag = context.getDiagnostics().Report(endianExpr->getLocStart(), AthenaError);
} diag.AddString("Endian value must be 'BigEndian' or 'LittleEndian'");
else diag.AddSourceRange(clang::CharSourceRange(endianExpr->getSourceRange(), true));
{ }
clang::DiagnosticBuilder diag = context.getDiagnostics().Report(field->getLocStart(), AthenaError); else
diag.AddString("Endian value must be 'BigEndian' or 'LittleEndian'"); {
diag.AddSourceRange(clang::CharSourceRange(field->getSourceRange(), true)); clang::DiagnosticBuilder diag = context.getDiagnostics().Report(field->getLocStart(), AthenaError);
diag.AddString("Endian value must be 'BigEndian' or 'LittleEndian'");
diag.AddSourceRange(clang::CharSourceRange(field->getSourceRange(), true));
}
} }
continue; continue;
} }
if (ioOp.empty()) if (ioOp.empty())
{ {
clang::DiagnosticBuilder diag = context.getDiagnostics().Report(field->getLocStart(), AthenaError); if (!p)
diag.AddString("Unable to use type '" + tsDecl->getNameAsString() + "' with Athena"); {
diag.AddSourceRange(clang::CharSourceRange(field->getSourceRange(), true)); clang::DiagnosticBuilder diag = context.getDiagnostics().Report(field->getLocStart(), AthenaError);
diag.AddString("Unable to use type '" + tsDecl->getNameAsString() + "' with Athena");
diag.AddSourceRange(clang::CharSourceRange(field->getSourceRange(), true));
}
continue; continue;
} }
@ -369,9 +381,12 @@ public:
endianExpr = defArg; endianExpr = defArg;
if (!defArg->isIntegerConstantExpr(endian, context)) if (!defArg->isIntegerConstantExpr(endian, context))
{ {
clang::DiagnosticBuilder diag = context.getDiagnostics().Report(defArg->getLocStart(), AthenaError); if (!p)
diag.AddString("Endian value must be 'BigEndian' or 'LittleEndian'"); {
diag.AddSourceRange(clang::CharSourceRange(defArg->getSourceRange(), true)); clang::DiagnosticBuilder diag = context.getDiagnostics().Report(defArg->getLocStart(), AthenaError);
diag.AddString("Endian value must be 'BigEndian' or 'LittleEndian'");
diag.AddSourceRange(clang::CharSourceRange(defArg->getSourceRange(), true));
}
continue; continue;
} }
} }
@ -417,9 +432,12 @@ public:
endianExpr = expr; endianExpr = expr;
if (!expr->isIntegerConstantExpr(endian, context)) if (!expr->isIntegerConstantExpr(endian, context))
{ {
clang::DiagnosticBuilder diag = context.getDiagnostics().Report(expr->getLocStart(), AthenaError); if (!p)
diag.AddString("Endian value must be 'BigEndian' or 'LittleEndian'"); {
diag.AddSourceRange(clang::CharSourceRange(expr->getSourceRange(), true)); clang::DiagnosticBuilder diag = context.getDiagnostics().Report(expr->getLocStart(), AthenaError);
diag.AddString("Endian value must be 'BigEndian' or 'LittleEndian'");
diag.AddSourceRange(clang::CharSourceRange(expr->getSourceRange(), true));
}
bad = true; bad = true;
break; break;
} }
@ -433,34 +451,43 @@ public:
int endianVal = endian.getSExtValue(); int endianVal = endian.getSExtValue();
if (endianVal != 0 && endianVal != 1) if (endianVal != 0 && endianVal != 1)
{ {
if (endianExpr) if (!p)
{ {
clang::DiagnosticBuilder diag = context.getDiagnostics().Report(endianExpr->getLocStart(), AthenaError); if (endianExpr)
diag.AddString("Endian value must be 'BigEndian' or 'LittleEndian'"); {
diag.AddSourceRange(clang::CharSourceRange(endianExpr->getSourceRange(), true)); clang::DiagnosticBuilder diag = context.getDiagnostics().Report(endianExpr->getLocStart(), AthenaError);
} diag.AddString("Endian value must be 'BigEndian' or 'LittleEndian'");
else diag.AddSourceRange(clang::CharSourceRange(endianExpr->getSourceRange(), true));
{ }
clang::DiagnosticBuilder diag = context.getDiagnostics().Report(field->getLocStart(), AthenaError); else
diag.AddString("Endian value must be 'BigEndian' or 'LittleEndian'"); {
diag.AddSourceRange(clang::CharSourceRange(field->getSourceRange(), true)); clang::DiagnosticBuilder diag = context.getDiagnostics().Report(field->getLocStart(), AthenaError);
diag.AddString("Endian value must be 'BigEndian' or 'LittleEndian'");
diag.AddSourceRange(clang::CharSourceRange(field->getSourceRange(), true));
}
} }
continue; continue;
} }
if (ioOp.empty()) if (ioOp.empty())
{ {
clang::DiagnosticBuilder diag = context.getDiagnostics().Report(field->getLocStart(), AthenaError); if (!p)
diag.AddString("Unable to use type '" + templateType.getAsString() + "' with Athena"); {
diag.AddSourceRange(clang::CharSourceRange(field->getSourceRange(), true)); clang::DiagnosticBuilder diag = context.getDiagnostics().Report(field->getLocStart(), AthenaError);
diag.AddString("Unable to use type '" + templateType.getAsString() + "' with Athena");
diag.AddSourceRange(clang::CharSourceRange(field->getSourceRange(), true));
}
continue; continue;
} }
if (sizeExpr.empty()) if (sizeExpr.empty())
{ {
clang::DiagnosticBuilder diag = context.getDiagnostics().Report(field->getLocStart(), AthenaError); if (!p)
diag.AddString("Unable to use count variable with Athena"); {
diag.AddSourceRange(clang::CharSourceRange(field->getSourceRange(), true)); clang::DiagnosticBuilder diag = context.getDiagnostics().Report(field->getLocStart(), AthenaError);
diag.AddString("Unable to use count variable with Athena");
diag.AddSourceRange(clang::CharSourceRange(field->getSourceRange(), true));
}
continue; continue;
} }
@ -485,7 +512,8 @@ public:
" " << fieldName << ".back()." << ioOp << "\n" " " << fieldName << ".back()." << ioOp << "\n"
" }\n"; " }\n";
else else
fileOut << " for (int i=0 ; i<(" << sizeExpr << ") ; ++i)\n " << fieldName << ".push_back(" << ioOp << ");\n"; fileOut << " for (int i=0 ; i<(" << sizeExpr << ") ; ++i)\n"
" " << fieldName << ".push_back(" << ioOp << ");\n";
} }
else else
{ {
@ -520,17 +548,20 @@ public:
} }
if (sizeExprStr.empty()) if (sizeExprStr.empty())
{ {
if (sizeExpr) if (!p)
{ {
clang::DiagnosticBuilder diag = context.getDiagnostics().Report(sizeExpr->getLocStart(), AthenaError); if (sizeExpr)
diag.AddString("Unable to use size variable with Athena"); {
diag.AddSourceRange(clang::CharSourceRange(sizeExpr->getSourceRange(), true)); clang::DiagnosticBuilder diag = context.getDiagnostics().Report(sizeExpr->getLocStart(), AthenaError);
} diag.AddString("Unable to use size variable with Athena");
else diag.AddSourceRange(clang::CharSourceRange(sizeExpr->getSourceRange(), true));
{ }
clang::DiagnosticBuilder diag = context.getDiagnostics().Report(field->getLocStart(), AthenaError); else
diag.AddString("Unable to use size variable with Athena"); {
diag.AddSourceRange(clang::CharSourceRange(field->getSourceRange(), true)); clang::DiagnosticBuilder diag = context.getDiagnostics().Report(field->getLocStart(), AthenaError);
diag.AddString("Unable to use size variable with Athena");
diag.AddSourceRange(clang::CharSourceRange(field->getSourceRange(), true));
}
} }
continue; continue;
} }
@ -594,9 +625,12 @@ public:
endianExpr = defArg; endianExpr = defArg;
if (!defArg->isIntegerConstantExpr(endian, context)) if (!defArg->isIntegerConstantExpr(endian, context))
{ {
clang::DiagnosticBuilder diag = context.getDiagnostics().Report(defArg->getLocStart(), AthenaError); if (!p)
diag.AddString("Endian value must be 'BigEndian' or 'LittleEndian'"); {
diag.AddSourceRange(clang::CharSourceRange(defArg->getSourceRange(), true)); clang::DiagnosticBuilder diag = context.getDiagnostics().Report(defArg->getLocStart(), AthenaError);
diag.AddString("Endian value must be 'BigEndian' or 'LittleEndian'");
diag.AddSourceRange(clang::CharSourceRange(defArg->getSourceRange(), true));
}
continue; continue;
} }
} }
@ -635,9 +669,12 @@ public:
endianExpr = expr; endianExpr = expr;
if (!expr->isIntegerConstantExpr(endian, context)) if (!expr->isIntegerConstantExpr(endian, context))
{ {
clang::DiagnosticBuilder diag = context.getDiagnostics().Report(expr->getLocStart(), AthenaError); if (!p)
diag.AddString("Endian value must be 'BigEndian' or 'LittleEndian'"); {
diag.AddSourceRange(clang::CharSourceRange(expr->getSourceRange(), true)); clang::DiagnosticBuilder diag = context.getDiagnostics().Report(expr->getLocStart(), AthenaError);
diag.AddString("Endian value must be 'BigEndian' or 'LittleEndian'");
diag.AddSourceRange(clang::CharSourceRange(expr->getSourceRange(), true));
}
bad = true; bad = true;
break; break;
} }
@ -651,17 +688,20 @@ public:
int endianVal = endian.getSExtValue(); int endianVal = endian.getSExtValue();
if (endianVal != 0 && endianVal != 1) if (endianVal != 0 && endianVal != 1)
{ {
if (endianExpr) if (!p)
{ {
clang::DiagnosticBuilder diag = context.getDiagnostics().Report(endianExpr->getLocStart(), AthenaError); if (endianExpr)
diag.AddString("Endian value must be 'BigEndian' or 'LittleEndian'"); {
diag.AddSourceRange(clang::CharSourceRange(endianExpr->getSourceRange(), true)); clang::DiagnosticBuilder diag = context.getDiagnostics().Report(endianExpr->getLocStart(), AthenaError);
} diag.AddString("Endian value must be 'BigEndian' or 'LittleEndian'");
else diag.AddSourceRange(clang::CharSourceRange(endianExpr->getSourceRange(), true));
{ }
clang::DiagnosticBuilder diag = context.getDiagnostics().Report(field->getLocStart(), AthenaError); else
diag.AddString("Endian value must be 'BigEndian' or 'LittleEndian'"); {
diag.AddSourceRange(clang::CharSourceRange(field->getSourceRange(), true)); clang::DiagnosticBuilder diag = context.getDiagnostics().Report(field->getLocStart(), AthenaError);
diag.AddString("Endian value must be 'BigEndian' or 'LittleEndian'");
diag.AddSourceRange(clang::CharSourceRange(field->getSourceRange(), true));
}
} }
continue; continue;
} }
@ -731,9 +771,12 @@ public:
{ {
if (!expr->isIntegerConstantExpr(offset, context)) if (!expr->isIntegerConstantExpr(offset, context))
{ {
clang::DiagnosticBuilder diag = context.getDiagnostics().Report(expr->getLocStart(), AthenaError); if (!p)
diag.AddString("Unable to use non-constant offset expression in Athena"); {
diag.AddSourceRange(clang::CharSourceRange(expr->getSourceRange(), true)); clang::DiagnosticBuilder diag = context.getDiagnostics().Report(expr->getLocStart(), AthenaError);
diag.AddString("Unable to use non-constant offset expression in Athena");
diag.AddSourceRange(clang::CharSourceRange(expr->getSourceRange(), true));
}
bad = true; bad = true;
break; break;
} }
@ -743,9 +786,12 @@ public:
directionExpr = expr; directionExpr = expr;
if (!expr->isIntegerConstantExpr(direction, context)) if (!expr->isIntegerConstantExpr(direction, context))
{ {
clang::DiagnosticBuilder diag = context.getDiagnostics().Report(expr->getLocStart(), AthenaError); if (!p)
diag.AddString("Unable to use non-constant direction expression in Athena"); {
diag.AddSourceRange(clang::CharSourceRange(expr->getSourceRange(), true)); clang::DiagnosticBuilder diag = context.getDiagnostics().Report(expr->getLocStart(), AthenaError);
diag.AddString("Unable to use non-constant direction expression in Athena");
diag.AddSourceRange(clang::CharSourceRange(expr->getSourceRange(), true));
}
bad = true; bad = true;
break; break;
} }
@ -760,17 +806,20 @@ public:
int64_t directionVal = direction.getSExtValue(); int64_t directionVal = direction.getSExtValue();
if (directionVal < 0 || directionVal > 2) if (directionVal < 0 || directionVal > 2)
{ {
if (directionExpr) if (!p)
{ {
clang::DiagnosticBuilder diag = context.getDiagnostics().Report(directionExpr->getLocStart(), AthenaError); if (directionExpr)
diag.AddString("Direction parameter must be 'Begin', 'Current', or 'End'"); {
diag.AddSourceRange(clang::CharSourceRange(directionExpr->getSourceRange(), true)); clang::DiagnosticBuilder diag = context.getDiagnostics().Report(directionExpr->getLocStart(), AthenaError);
} diag.AddString("Direction parameter must be 'Begin', 'Current', or 'End'");
else diag.AddSourceRange(clang::CharSourceRange(directionExpr->getSourceRange(), true));
{ }
clang::DiagnosticBuilder diag = context.getDiagnostics().Report(field->getLocStart(), AthenaError); else
diag.AddString("Direction parameter must be 'Begin', 'Current', or 'End'"); {
diag.AddSourceRange(clang::CharSourceRange(field->getSourceRange(), true)); clang::DiagnosticBuilder diag = context.getDiagnostics().Report(field->getLocStart(), AthenaError);
diag.AddString("Direction parameter must be 'Begin', 'Current', or 'End'");
diag.AddSourceRange(clang::CharSourceRange(field->getSourceRange(), true));
}
} }
continue; continue;
} }
@ -810,9 +859,12 @@ public:
const clang::Expr* expr = arg.getAsExpr(); const clang::Expr* expr = arg.getAsExpr();
if (!expr->isIntegerConstantExpr(align, context)) if (!expr->isIntegerConstantExpr(align, context))
{ {
clang::DiagnosticBuilder diag = context.getDiagnostics().Report(expr->getLocStart(), AthenaError); if (!p)
diag.AddString("Unable to use non-constant align expression in Athena"); {
diag.AddSourceRange(clang::CharSourceRange(expr->getSourceRange(), true)); clang::DiagnosticBuilder diag = context.getDiagnostics().Report(expr->getLocStart(), AthenaError);
diag.AddString("Unable to use non-constant align expression in Athena");
diag.AddSourceRange(clang::CharSourceRange(expr->getSourceRange(), true));
}
bad = true; bad = true;
break; break;
} }
@ -835,16 +887,16 @@ public:
else if (align.isPowerOf2()) else if (align.isPowerOf2())
{ {
if (!p) if (!p)
fileOut << " reader.seek((reader.position() + " << alignVal-1 << ") & ~" << alignVal-1 << ", SeekOrigin::Begin);\n"; fileOut << " reader.seek((reader.position() + " << alignVal-1 << ") & ~" << alignVal-1 << ", Athena::Begin);\n";
else else
fileOut << " writer.seek((writer.position() + " << alignVal-1 << ") & ~" << alignVal-1 << ", SeekOrigin::Begin);\n"; fileOut << " writer.seek((writer.position() + " << alignVal-1 << ") & ~" << alignVal-1 << ", Athena::Begin);\n";
} }
else else
{ {
if (!p) if (!p)
fileOut << " reader.seek((reader.position() + " << alignVal-1 << ") / " << alignVal << " * " << alignVal << ", SeekOrigin::Begin);\n"; fileOut << " reader.seek((reader.position() + " << alignVal-1 << ") / " << alignVal << " * " << alignVal << ", Athena::Begin);\n";
else else
fileOut << " writer.seek((writer.position() + " << alignVal-1 << ") / " << alignVal << " * " << alignVal << ", SeekOrigin::Begin);\n"; fileOut << " writer.seek((writer.position() + " << alignVal-1 << ") / " << alignVal << " * " << alignVal << ", Athena::Begin);\n";
} }
} }
} }