mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-11-30 17:21:10 +00:00
[clang] Allow printing 64 bit ints in diagnostics
Currently we're limited to 32 bit ints in diagnostics. With support for 4GB alignments coming soon, we need to report 4GB as the max alignment allowed. I've tested that this does indeed properly print 2^32. Reviewed By: rsmith Differential Revision: https://reviews.llvm.org/D111184
This commit is contained in:
parent
00eec5c1b7
commit
afdac5fbcb
@ -374,8 +374,7 @@ struct ParsedTargetAttr {
|
||||
|
||||
inline const StreamingDiagnostic &operator<<(const StreamingDiagnostic &DB,
|
||||
const Attr *At) {
|
||||
DB.AddTaggedVal(reinterpret_cast<intptr_t>(At),
|
||||
DiagnosticsEngine::ak_attr);
|
||||
DB.AddTaggedVal(reinterpret_cast<uint64_t>(At), DiagnosticsEngine::ak_attr);
|
||||
return DB;
|
||||
}
|
||||
} // end namespace clang
|
||||
|
@ -4589,7 +4589,7 @@ public:
|
||||
/// into a diagnostic with <<.
|
||||
inline const StreamingDiagnostic &operator<<(const StreamingDiagnostic &PD,
|
||||
const NamedDecl *ND) {
|
||||
PD.AddTaggedVal(reinterpret_cast<intptr_t>(ND),
|
||||
PD.AddTaggedVal(reinterpret_cast<uint64_t>(ND),
|
||||
DiagnosticsEngine::ak_nameddecl);
|
||||
return PD;
|
||||
}
|
||||
|
@ -521,7 +521,7 @@ public:
|
||||
/// NestedNameSpecifiers into a diagnostic with <<.
|
||||
inline const StreamingDiagnostic &operator<<(const StreamingDiagnostic &DB,
|
||||
NestedNameSpecifier *NNS) {
|
||||
DB.AddTaggedVal(reinterpret_cast<intptr_t>(NNS),
|
||||
DB.AddTaggedVal(reinterpret_cast<uint64_t>(NNS),
|
||||
DiagnosticsEngine::ak_nestednamespec);
|
||||
return DB;
|
||||
}
|
||||
|
@ -7146,7 +7146,7 @@ inline const StreamingDiagnostic &operator<<(const StreamingDiagnostic &PD,
|
||||
/// into a diagnostic with <<.
|
||||
inline const StreamingDiagnostic &operator<<(const StreamingDiagnostic &PD,
|
||||
QualType T) {
|
||||
PD.AddTaggedVal(reinterpret_cast<intptr_t>(T.getAsOpaquePtr()),
|
||||
PD.AddTaggedVal(reinterpret_cast<uint64_t>(T.getAsOpaquePtr()),
|
||||
DiagnosticsEngine::ak_qualtype);
|
||||
return PD;
|
||||
}
|
||||
|
@ -164,9 +164,9 @@ struct DiagnosticStorage {
|
||||
/// The values for the various substitution positions.
|
||||
///
|
||||
/// This is used when the argument is not an std::string. The specific value
|
||||
/// is mangled into an intptr_t and the interpretation depends on exactly
|
||||
/// is mangled into an uint64_t and the interpretation depends on exactly
|
||||
/// what sort of argument kind it is.
|
||||
intptr_t DiagArgumentsVal[MaxArguments];
|
||||
uint64_t DiagArgumentsVal[MaxArguments];
|
||||
|
||||
/// The values for the various substitution positions that have
|
||||
/// string arguments.
|
||||
@ -1179,7 +1179,7 @@ public:
|
||||
DiagStorage = nullptr;
|
||||
}
|
||||
|
||||
void AddTaggedVal(intptr_t V, DiagnosticsEngine::ArgumentKind Kind) const {
|
||||
void AddTaggedVal(uint64_t V, DiagnosticsEngine::ArgumentKind Kind) const {
|
||||
if (!DiagStorage)
|
||||
DiagStorage = getStorage();
|
||||
|
||||
@ -1402,6 +1402,12 @@ inline const StreamingDiagnostic &operator<<(const StreamingDiagnostic &DB,
|
||||
return DB;
|
||||
}
|
||||
|
||||
inline const StreamingDiagnostic &operator<<(const StreamingDiagnostic &DB,
|
||||
int64_t I) {
|
||||
DB.AddTaggedVal(I, DiagnosticsEngine::ak_sint);
|
||||
return DB;
|
||||
}
|
||||
|
||||
// We use enable_if here to prevent that this overload is selected for
|
||||
// pointers or other arguments that are implicitly convertible to bool.
|
||||
template <typename T>
|
||||
@ -1418,6 +1424,12 @@ inline const StreamingDiagnostic &operator<<(const StreamingDiagnostic &DB,
|
||||
return DB;
|
||||
}
|
||||
|
||||
inline const StreamingDiagnostic &operator<<(const StreamingDiagnostic &DB,
|
||||
uint64_t I) {
|
||||
DB.AddTaggedVal(I, DiagnosticsEngine::ak_uint);
|
||||
return DB;
|
||||
}
|
||||
|
||||
inline const StreamingDiagnostic &operator<<(const StreamingDiagnostic &DB,
|
||||
tok::TokenKind I) {
|
||||
DB.AddTaggedVal(static_cast<unsigned>(I), DiagnosticsEngine::ak_tokenkind);
|
||||
@ -1580,18 +1592,18 @@ public:
|
||||
|
||||
/// Return the specified signed integer argument.
|
||||
/// \pre getArgKind(Idx) == DiagnosticsEngine::ak_sint
|
||||
int getArgSInt(unsigned Idx) const {
|
||||
int64_t getArgSInt(unsigned Idx) const {
|
||||
assert(getArgKind(Idx) == DiagnosticsEngine::ak_sint &&
|
||||
"invalid argument accessor!");
|
||||
return (int)DiagObj->DiagStorage.DiagArgumentsVal[Idx];
|
||||
return (int64_t)DiagObj->DiagStorage.DiagArgumentsVal[Idx];
|
||||
}
|
||||
|
||||
/// Return the specified unsigned integer argument.
|
||||
/// \pre getArgKind(Idx) == DiagnosticsEngine::ak_uint
|
||||
unsigned getArgUInt(unsigned Idx) const {
|
||||
uint64_t getArgUInt(unsigned Idx) const {
|
||||
assert(getArgKind(Idx) == DiagnosticsEngine::ak_uint &&
|
||||
"invalid argument accessor!");
|
||||
return (unsigned)DiagObj->DiagStorage.DiagArgumentsVal[Idx];
|
||||
return DiagObj->DiagStorage.DiagArgumentsVal[Idx];
|
||||
}
|
||||
|
||||
/// Return the specified IdentifierInfo argument.
|
||||
@ -1605,7 +1617,7 @@ public:
|
||||
|
||||
/// Return the specified non-string argument in an opaque form.
|
||||
/// \pre getArgKind(Idx) != DiagnosticsEngine::ak_std_string
|
||||
intptr_t getRawArg(unsigned Idx) const {
|
||||
uint64_t getRawArg(unsigned Idx) const {
|
||||
assert(getArgKind(Idx) != DiagnosticsEngine::ak_std_string &&
|
||||
"invalid argument accessor!");
|
||||
return DiagObj->DiagStorage.DiagArgumentsVal[Idx];
|
||||
|
@ -1119,14 +1119,14 @@ enum AttributeDeclKind {
|
||||
|
||||
inline const StreamingDiagnostic &operator<<(const StreamingDiagnostic &DB,
|
||||
const ParsedAttr &At) {
|
||||
DB.AddTaggedVal(reinterpret_cast<intptr_t>(At.getAttrName()),
|
||||
DB.AddTaggedVal(reinterpret_cast<uint64_t>(At.getAttrName()),
|
||||
DiagnosticsEngine::ak_identifierinfo);
|
||||
return DB;
|
||||
}
|
||||
|
||||
inline const StreamingDiagnostic &operator<<(const StreamingDiagnostic &DB,
|
||||
const ParsedAttr *At) {
|
||||
DB.AddTaggedVal(reinterpret_cast<intptr_t>(At->getAttrName()),
|
||||
DB.AddTaggedVal(reinterpret_cast<uint64_t>(At->getAttrName()),
|
||||
DiagnosticsEngine::ak_identifierinfo);
|
||||
return DB;
|
||||
}
|
||||
@ -1141,7 +1141,7 @@ template <typename ACI,
|
||||
std::is_same<ACI, AttributeCommonInfo>::value, int> = 0>
|
||||
inline const StreamingDiagnostic &operator<<(const StreamingDiagnostic &DB,
|
||||
const ACI &CI) {
|
||||
DB.AddTaggedVal(reinterpret_cast<intptr_t>(CI.getAttrName()),
|
||||
DB.AddTaggedVal(reinterpret_cast<uint64_t>(CI.getAttrName()),
|
||||
DiagnosticsEngine::ak_identifierinfo);
|
||||
return DB;
|
||||
}
|
||||
@ -1151,7 +1151,7 @@ template <typename ACI,
|
||||
std::is_same<ACI, AttributeCommonInfo>::value, int> = 0>
|
||||
inline const StreamingDiagnostic &operator<<(const StreamingDiagnostic &DB,
|
||||
const ACI* CI) {
|
||||
DB.AddTaggedVal(reinterpret_cast<intptr_t>(CI->getAttrName()),
|
||||
DB.AddTaggedVal(reinterpret_cast<uint64_t>(CI->getAttrName()),
|
||||
DiagnosticsEngine::ak_identifierinfo);
|
||||
return DB;
|
||||
}
|
||||
|
@ -932,7 +932,7 @@ FormatDiagnostic(const char *DiagStr, const char *DiagEnd,
|
||||
}
|
||||
// ---- INTEGERS ----
|
||||
case DiagnosticsEngine::ak_sint: {
|
||||
int Val = getArgSInt(ArgNo);
|
||||
int64_t Val = getArgSInt(ArgNo);
|
||||
|
||||
if (ModifierIs(Modifier, ModifierLen, "select")) {
|
||||
HandleSelectModifier(*this, (unsigned)Val, Argument, ArgumentLen,
|
||||
@ -951,7 +951,7 @@ FormatDiagnostic(const char *DiagStr, const char *DiagEnd,
|
||||
break;
|
||||
}
|
||||
case DiagnosticsEngine::ak_uint: {
|
||||
unsigned Val = getArgUInt(ArgNo);
|
||||
uint64_t Val = getArgUInt(ArgNo);
|
||||
|
||||
if (ModifierIs(Modifier, ModifierLen, "select")) {
|
||||
HandleSelectModifier(*this, Val, Argument, ArgumentLen, OutStr);
|
||||
|
Loading…
Reference in New Issue
Block a user