Skip to content

Commit 0ab2216

Browse files
aeubanksmemfrob
authored andcommitted
Revert "[clang] Allow printing 64 bit ints in diagnostics"
This reverts commit edfff2f8b0435bc4af94bd3b41bf57244d84d993. Breaks clang-tidy.
1 parent 41ff517 commit 0ab2216

File tree

7 files changed

+19
-18
lines changed

7 files changed

+19
-18
lines changed

clang/include/clang/AST/Attr.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,8 @@ struct ParsedTargetAttr {
374374

375375
inline const StreamingDiagnostic &operator<<(const StreamingDiagnostic &DB,
376376
const Attr *At) {
377-
DB.AddTaggedVal(reinterpret_cast<uint64_t>(At), DiagnosticsEngine::ak_attr);
377+
DB.AddTaggedVal(reinterpret_cast<intptr_t>(At),
378+
DiagnosticsEngine::ak_attr);
378379
return DB;
379380
}
380381
} // end namespace clang

clang/include/clang/AST/Decl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4589,7 +4589,7 @@ class EmptyDecl : public Decl {
45894589
/// into a diagnostic with <<.
45904590
inline const StreamingDiagnostic &operator<<(const StreamingDiagnostic &PD,
45914591
const NamedDecl *ND) {
4592-
PD.AddTaggedVal(reinterpret_cast<uint64_t>(ND),
4592+
PD.AddTaggedVal(reinterpret_cast<intptr_t>(ND),
45934593
DiagnosticsEngine::ak_nameddecl);
45944594
return PD;
45954595
}

clang/include/clang/AST/NestedNameSpecifier.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,7 @@ class NestedNameSpecifierLocBuilder {
521521
/// NestedNameSpecifiers into a diagnostic with <<.
522522
inline const StreamingDiagnostic &operator<<(const StreamingDiagnostic &DB,
523523
NestedNameSpecifier *NNS) {
524-
DB.AddTaggedVal(reinterpret_cast<uint64_t>(NNS),
524+
DB.AddTaggedVal(reinterpret_cast<intptr_t>(NNS),
525525
DiagnosticsEngine::ak_nestednamespec);
526526
return DB;
527527
}

clang/include/clang/AST/Type.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7146,7 +7146,7 @@ inline const StreamingDiagnostic &operator<<(const StreamingDiagnostic &PD,
71467146
/// into a diagnostic with <<.
71477147
inline const StreamingDiagnostic &operator<<(const StreamingDiagnostic &PD,
71487148
QualType T) {
7149-
PD.AddTaggedVal(reinterpret_cast<uint64_t>(T.getAsOpaquePtr()),
7149+
PD.AddTaggedVal(reinterpret_cast<intptr_t>(T.getAsOpaquePtr()),
71507150
DiagnosticsEngine::ak_qualtype);
71517151
return PD;
71527152
}

clang/include/clang/Basic/Diagnostic.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,9 @@ struct DiagnosticStorage {
164164
/// The values for the various substitution positions.
165165
///
166166
/// This is used when the argument is not an std::string. The specific value
167-
/// is mangled into an uint64_t and the interpretation depends on exactly
167+
/// is mangled into an intptr_t and the interpretation depends on exactly
168168
/// what sort of argument kind it is.
169-
uint64_t DiagArgumentsVal[MaxArguments];
169+
intptr_t DiagArgumentsVal[MaxArguments];
170170

171171
/// The values for the various substitution positions that have
172172
/// string arguments.
@@ -1179,7 +1179,7 @@ class StreamingDiagnostic {
11791179
DiagStorage = nullptr;
11801180
}
11811181

1182-
void AddTaggedVal(uint64_t V, DiagnosticsEngine::ArgumentKind Kind) const {
1182+
void AddTaggedVal(intptr_t V, DiagnosticsEngine::ArgumentKind Kind) const {
11831183
if (!DiagStorage)
11841184
DiagStorage = getStorage();
11851185

@@ -1580,18 +1580,18 @@ class Diagnostic {
15801580

15811581
/// Return the specified signed integer argument.
15821582
/// \pre getArgKind(Idx) == DiagnosticsEngine::ak_sint
1583-
int64_t getArgSInt(unsigned Idx) const {
1583+
int getArgSInt(unsigned Idx) const {
15841584
assert(getArgKind(Idx) == DiagnosticsEngine::ak_sint &&
15851585
"invalid argument accessor!");
1586-
return (int64_t)DiagObj->DiagStorage.DiagArgumentsVal[Idx];
1586+
return (int)DiagObj->DiagStorage.DiagArgumentsVal[Idx];
15871587
}
15881588

15891589
/// Return the specified unsigned integer argument.
15901590
/// \pre getArgKind(Idx) == DiagnosticsEngine::ak_uint
1591-
uint64_t getArgUInt(unsigned Idx) const {
1591+
unsigned getArgUInt(unsigned Idx) const {
15921592
assert(getArgKind(Idx) == DiagnosticsEngine::ak_uint &&
15931593
"invalid argument accessor!");
1594-
return DiagObj->DiagStorage.DiagArgumentsVal[Idx];
1594+
return (unsigned)DiagObj->DiagStorage.DiagArgumentsVal[Idx];
15951595
}
15961596

15971597
/// Return the specified IdentifierInfo argument.
@@ -1605,7 +1605,7 @@ class Diagnostic {
16051605

16061606
/// Return the specified non-string argument in an opaque form.
16071607
/// \pre getArgKind(Idx) != DiagnosticsEngine::ak_std_string
1608-
uint64_t getRawArg(unsigned Idx) const {
1608+
intptr_t getRawArg(unsigned Idx) const {
16091609
assert(getArgKind(Idx) != DiagnosticsEngine::ak_std_string &&
16101610
"invalid argument accessor!");
16111611
return DiagObj->DiagStorage.DiagArgumentsVal[Idx];

clang/include/clang/Sema/ParsedAttr.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1119,14 +1119,14 @@ enum AttributeDeclKind {
11191119

11201120
inline const StreamingDiagnostic &operator<<(const StreamingDiagnostic &DB,
11211121
const ParsedAttr &At) {
1122-
DB.AddTaggedVal(reinterpret_cast<uint64_t>(At.getAttrName()),
1122+
DB.AddTaggedVal(reinterpret_cast<intptr_t>(At.getAttrName()),
11231123
DiagnosticsEngine::ak_identifierinfo);
11241124
return DB;
11251125
}
11261126

11271127
inline const StreamingDiagnostic &operator<<(const StreamingDiagnostic &DB,
11281128
const ParsedAttr *At) {
1129-
DB.AddTaggedVal(reinterpret_cast<uint64_t>(At->getAttrName()),
1129+
DB.AddTaggedVal(reinterpret_cast<intptr_t>(At->getAttrName()),
11301130
DiagnosticsEngine::ak_identifierinfo);
11311131
return DB;
11321132
}
@@ -1141,7 +1141,7 @@ template <typename ACI,
11411141
std::is_same<ACI, AttributeCommonInfo>::value, int> = 0>
11421142
inline const StreamingDiagnostic &operator<<(const StreamingDiagnostic &DB,
11431143
const ACI &CI) {
1144-
DB.AddTaggedVal(reinterpret_cast<uint64_t>(CI.getAttrName()),
1144+
DB.AddTaggedVal(reinterpret_cast<intptr_t>(CI.getAttrName()),
11451145
DiagnosticsEngine::ak_identifierinfo);
11461146
return DB;
11471147
}
@@ -1151,7 +1151,7 @@ template <typename ACI,
11511151
std::is_same<ACI, AttributeCommonInfo>::value, int> = 0>
11521152
inline const StreamingDiagnostic &operator<<(const StreamingDiagnostic &DB,
11531153
const ACI* CI) {
1154-
DB.AddTaggedVal(reinterpret_cast<uint64_t>(CI->getAttrName()),
1154+
DB.AddTaggedVal(reinterpret_cast<intptr_t>(CI->getAttrName()),
11551155
DiagnosticsEngine::ak_identifierinfo);
11561156
return DB;
11571157
}

clang/lib/Basic/Diagnostic.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -932,7 +932,7 @@ FormatDiagnostic(const char *DiagStr, const char *DiagEnd,
932932
}
933933
// ---- INTEGERS ----
934934
case DiagnosticsEngine::ak_sint: {
935-
int64_t Val = getArgSInt(ArgNo);
935+
int Val = getArgSInt(ArgNo);
936936

937937
if (ModifierIs(Modifier, ModifierLen, "select")) {
938938
HandleSelectModifier(*this, (unsigned)Val, Argument, ArgumentLen,
@@ -951,7 +951,7 @@ FormatDiagnostic(const char *DiagStr, const char *DiagEnd,
951951
break;
952952
}
953953
case DiagnosticsEngine::ak_uint: {
954-
uint64_t Val = getArgUInt(ArgNo);
954+
unsigned Val = getArgUInt(ArgNo);
955955

956956
if (ModifierIs(Modifier, ModifierLen, "select")) {
957957
HandleSelectModifier(*this, Val, Argument, ArgumentLen, OutStr);

0 commit comments

Comments
 (0)