Skip to content

Commit b05a11a

Browse files
committed
Change type of DiagnosticHandlerTy
Newer versions of clang include -Wcast-function-type-mismatch in -Wextra, which triggers a warning when we cast between function pointers that differ between a pointer and a reference in an argument. Resolve this by making the types consistent. This change is equivalent to llvm/llvm-project#86504 from upstream.
1 parent 4e0f536 commit b05a11a

File tree

6 files changed

+11
-11
lines changed

6 files changed

+11
-11
lines changed

include/dxc/DxilValidation/DxilValidation.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ class PrintDiagnosticContext {
8181
bool HasWarnings() const;
8282
void Handle(const llvm::DiagnosticInfo &DI);
8383

84-
static void PrintDiagnosticHandler(const llvm::DiagnosticInfo &DI,
84+
static void PrintDiagnosticHandler(const llvm::DiagnosticInfo *DI,
8585
void *Context);
8686
};
8787

include/llvm/IR/LLVMContext.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ class LLVMContext {
8383
/// Defines the type of a diagnostic handler.
8484
/// \see LLVMContext::setDiagnosticHandler.
8585
/// \see LLVMContext::diagnose.
86-
typedef void (*DiagnosticHandlerTy)(const DiagnosticInfo &DI, void *Context);
86+
typedef void (*DiagnosticHandlerTy)(const DiagnosticInfo *DI, void *Context);
8787

8888
/// Defines the type of a yield callback.
8989
/// \see LLVMContext::setYieldCallback.

lib/DxilValidation/DxilValidation.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,9 @@ void PrintDiagnosticContext::Handle(const DiagnosticInfo &DI) {
8585
m_Printer << "\n";
8686
}
8787

88-
void PrintDiagnosticContext::PrintDiagnosticHandler(const DiagnosticInfo &DI,
88+
void PrintDiagnosticContext::PrintDiagnosticHandler(const DiagnosticInfo *DI,
8989
void *Context) {
90-
reinterpret_cast<hlsl::PrintDiagnosticContext *>(Context)->Handle(DI);
90+
reinterpret_cast<hlsl::PrintDiagnosticContext *>(Context)->Handle(*DI);
9191
}
9292

9393
struct PSExecutionInfo {

lib/IR/LLVMContext.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ void LLVMContext::diagnose(const DiagnosticInfo &DI) {
227227
// If there is a report handler, use it.
228228
if (pImpl->DiagnosticHandler) {
229229
if (!pImpl->RespectDiagnosticFilters || isDiagnosticEnabled(DI))
230-
pImpl->DiagnosticHandler(DI, pImpl->DiagnosticContext);
230+
pImpl->DiagnosticHandler(&DI, pImpl->DiagnosticContext);
231231
return;
232232
}
233233

tools/clang/lib/CodeGen/CodeGenAction.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,9 +238,9 @@ namespace clang {
238238

239239
void linkerDiagnosticHandler(const llvm::DiagnosticInfo &DI);
240240

241-
static void DiagnosticHandler(const llvm::DiagnosticInfo &DI,
241+
static void DiagnosticHandler(const llvm::DiagnosticInfo *DI,
242242
void *Context) {
243-
((BackendConsumer *)Context)->DiagnosticHandlerImpl(DI);
243+
((BackendConsumer *)Context)->DiagnosticHandlerImpl(*DI);
244244
}
245245

246246
void InlineAsmDiagHandler2(const llvm::SMDiagnostic &,

tools/llvm-dis/llvm-dis.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,21 +115,21 @@ class CommentWriter : public AssemblyAnnotationWriter {
115115

116116
} // end anon namespace
117117

118-
static void diagnosticHandler(const DiagnosticInfo &DI, void *Context) {
118+
static void diagnosticHandler(const DiagnosticInfo *DI, void *Context) {
119119
raw_ostream &OS = errs();
120120
OS << (char *)Context << ": ";
121-
switch (DI.getSeverity()) {
121+
switch (DI->getSeverity()) {
122122
case DS_Error: OS << "error: "; break;
123123
case DS_Warning: OS << "warning: "; break;
124124
case DS_Remark: OS << "remark: "; break;
125125
case DS_Note: OS << "note: "; break;
126126
}
127127

128128
DiagnosticPrinterRawOStream DP(OS);
129-
DI.print(DP);
129+
DI->print(DP);
130130
OS << '\n';
131131

132-
if (DI.getSeverity() == DS_Error)
132+
if (DI->getSeverity() == DS_Error)
133133
exit(1);
134134
}
135135

0 commit comments

Comments
 (0)