forked from OSchip/llvm-project
[mlir][CAPI][test] Change casts and fprintf format strings from long to intptr_t
A test in ir.c makes use of casting a void* to an integer type to print it's address. This cast is currently done with the datatype `long` however, which is only guaranteed to be equal to the pointer width on LP64 system. Other platforms may use a length not equal to the pointer width. 64bit Windows as an example uses 32 bit for `long` which does not match the 64 bit pointers. This also results in clang warning due to `-Wvoid-pointer-to-int-cast`. Technically speaking, since the test only passes the value 42, it does not cause any issues, but it'd be nice to fix the warning at least. Differential Revision: https://reviews.llvm.org/D103085
This commit is contained in:
parent
1872283457
commit
09b5ebc07b
|
@ -21,6 +21,7 @@
|
|||
#include "mlir-c/Registration.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <inttypes.h>
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -1597,7 +1598,7 @@ int testOperands() {
|
|||
|
||||
// Test operand APIs.
|
||||
intptr_t numOperands = mlirOperationGetNumOperands(op);
|
||||
fprintf(stderr, "Num Operands: %ld\n", numOperands);
|
||||
fprintf(stderr, "Num Operands: %" PRIdPTR "\n", numOperands);
|
||||
// CHECK: Num Operands: 1
|
||||
|
||||
MlirValue opOperand = mlirOperationGetOperand(op, 0);
|
||||
|
@ -1653,19 +1654,22 @@ int testClone() {
|
|||
|
||||
// Wraps a diagnostic into additional text we can match against.
|
||||
MlirLogicalResult errorHandler(MlirDiagnostic diagnostic, void *userData) {
|
||||
fprintf(stderr, "processing diagnostic (userData: %ld) <<\n", (long)userData);
|
||||
fprintf(stderr, "processing diagnostic (userData: %" PRIdPTR ") <<\n",
|
||||
(intptr_t)userData);
|
||||
mlirDiagnosticPrint(diagnostic, printToStderr, NULL);
|
||||
fprintf(stderr, "\n");
|
||||
MlirLocation loc = mlirDiagnosticGetLocation(diagnostic);
|
||||
mlirLocationPrint(loc, printToStderr, NULL);
|
||||
assert(mlirDiagnosticGetNumNotes(diagnostic) == 0);
|
||||
fprintf(stderr, "\n>> end of diagnostic (userData: %ld)\n", (long)userData);
|
||||
fprintf(stderr, "\n>> end of diagnostic (userData: %" PRIdPTR ")\n",
|
||||
(intptr_t)userData);
|
||||
return mlirLogicalResultSuccess();
|
||||
}
|
||||
|
||||
// Logs when the delete user data callback is called
|
||||
static void deleteUserData(void *userData) {
|
||||
fprintf(stderr, "deleting user data (userData: %ld)\n", (long)userData);
|
||||
fprintf(stderr, "deleting user data (userData: %" PRIdPTR ")\n",
|
||||
(intptr_t)userData);
|
||||
}
|
||||
|
||||
void testDiagnostics() {
|
||||
|
|
Loading…
Reference in New Issue