Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions clang/include/clang/Basic/Diagnostic.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "llvm/ADT/IntrusiveRefCntPtr.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/iterator_range.h"
#include "llvm/Support/Compiler.h"
#include <cassert>
Expand Down Expand Up @@ -1366,6 +1367,22 @@ inline const StreamingDiagnostic &operator<<(const StreamingDiagnostic &DB,
return DB;
}

inline const StreamingDiagnostic &operator<<(const StreamingDiagnostic &DB,
const llvm::APSInt &Int) {
DB.AddString(toString(Int, /*Radix=*/10, Int.isSigned(),
/*formatAsCLiteral=*/false,
/*UpperCase=*/true, /*InsertSeparators=*/true));
return DB;
}

inline const StreamingDiagnostic &operator<<(const StreamingDiagnostic &DB,
const llvm::APInt &Int) {
DB.AddString(toString(Int, /*Radix=*/10, /*Signed=*/false,
/*formatAsCLiteral=*/false,
/*UpperCase=*/true, /*InsertSeparators=*/true));
return DB;
}

inline const StreamingDiagnostic &operator<<(const StreamingDiagnostic &DB,
int I) {
DB.AddTaggedVal(I, DiagnosticsEngine::ak_sint);
Expand Down
3 changes: 1 addition & 2 deletions clang/lib/Sema/SemaDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18909,8 +18909,7 @@ ExprResult Sema::VerifyBitField(SourceLocation FieldLoc,
// 'bool'.
if (BitfieldIsOverwide && !FieldTy->isBooleanType() && FieldName) {
Diag(FieldLoc, diag::warn_bitfield_width_exceeds_type_width)
<< FieldName << toString(Value, 10)
<< (unsigned)TypeWidth;
<< FieldName << Value << (unsigned)TypeWidth;
}
}

Expand Down
2 changes: 1 addition & 1 deletion clang/test/SemaCXX/bitfield-layout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ CHECK_SIZE(Test4, 8);
CHECK_ALIGN(Test4, 8);

struct Test5 {
char c : 0x100000001; // expected-warning {{width of bit-field 'c' (4294967297 bits) exceeds the width of its type; value will be truncated to 8 bits}}
char c : 0x100000001; // expected-warning {{width of bit-field 'c' (4'294'967'297 bits) exceeds the width of its type; value will be truncated to 8 bits}}
};
// Size and align don't really matter here, just make sure we don't crash.
CHECK_SIZE(Test5, 1);
Expand Down