diff --git a/mlir/include/mlir-c/BuiltinAttributes.h b/mlir/include/mlir-c/BuiltinAttributes.h --- a/mlir/include/mlir-c/BuiltinAttributes.h +++ b/mlir/include/mlir-c/BuiltinAttributes.h @@ -23,7 +23,7 @@ #endif /// Returns an empty attribute. -MLIR_CAPI_EXPORTED MlirAttribute mlirAttributeGetNull(); +MLIR_CAPI_EXPORTED MlirAttribute mlirAttributeGetNull(void); //===----------------------------------------------------------------------===// // Affine map attribute. diff --git a/mlir/include/mlir-c/BuiltinTypes.h b/mlir/include/mlir-c/BuiltinTypes.h --- a/mlir/include/mlir-c/BuiltinTypes.h +++ b/mlir/include/mlir-c/BuiltinTypes.h @@ -166,7 +166,7 @@ /// Returns the value indicating a dynamic size in a shaped type. Prefer /// mlirShapedTypeIsDynamicSize to direct comparisons with this value. -MLIR_CAPI_EXPORTED int64_t mlirShapedTypeGetDynamicSize(); +MLIR_CAPI_EXPORTED int64_t mlirShapedTypeGetDynamicSize(void); /// Checks whether the given value is used as a placeholder for dynamic strides /// and offsets in shaped types. @@ -175,7 +175,7 @@ /// Returns the value indicating a dynamic stride or offset in a shaped type. /// Prefer mlirShapedTypeGetDynamicStrideOrOffset to direct comparisons with /// this value. -MLIR_CAPI_EXPORTED int64_t mlirShapedTypeGetDynamicStrideOrOffset(); +MLIR_CAPI_EXPORTED int64_t mlirShapedTypeGetDynamicStrideOrOffset(void); //===----------------------------------------------------------------------===// // Vector type. diff --git a/mlir/include/mlir-c/Dialect/Quant.h b/mlir/include/mlir-c/Dialect/Quant.h --- a/mlir/include/mlir-c/Dialect/Quant.h +++ b/mlir/include/mlir-c/Dialect/Quant.h @@ -26,7 +26,7 @@ MLIR_CAPI_EXPORTED bool mlirTypeIsAQuantizedType(MlirType type); /// Returns the bit flag used to indicate signedness of a quantized type. -MLIR_CAPI_EXPORTED unsigned mlirQuantizedTypeGetSignedFlag(); +MLIR_CAPI_EXPORTED unsigned mlirQuantizedTypeGetSignedFlag(void); /// Returns the minimum possible value stored by a quantized type. MLIR_CAPI_EXPORTED int64_t mlirQuantizedTypeGetDefaultMinimumForInteger( diff --git a/mlir/include/mlir-c/IR.h b/mlir/include/mlir-c/IR.h --- a/mlir/include/mlir-c/IR.h +++ b/mlir/include/mlir-c/IR.h @@ -82,7 +82,7 @@ //===----------------------------------------------------------------------===// /// Creates an MLIR context and transfers its ownership to the caller. -MLIR_CAPI_EXPORTED MlirContext mlirContextCreate(); +MLIR_CAPI_EXPORTED MlirContext mlirContextCreate(void); /// Checks if two contexts are equal. MLIR_CAPI_EXPORTED bool mlirContextEqual(MlirContext ctx1, MlirContext ctx2); @@ -184,7 +184,8 @@ typedef struct MlirDialectHandle MlirDialectHandle; #define MLIR_DECLARE_CAPI_DIALECT_REGISTRATION(Name, Namespace) \ - MLIR_CAPI_EXPORTED MlirDialectHandle mlirGetDialectHandle__##Namespace##__() + MLIR_CAPI_EXPORTED MlirDialectHandle mlirGetDialectHandle__##Namespace##__( \ + void) /// Returns the namespace associated with the provided dialect handle. MLIR_CAPI_EXPORTED @@ -208,7 +209,7 @@ //===----------------------------------------------------------------------===// /// Creates a dialect registry and transfers its ownership to the caller. -MLIR_CAPI_EXPORTED MlirDialectRegistry mlirDialectRegistryCreate(); +MLIR_CAPI_EXPORTED MlirDialectRegistry mlirDialectRegistryCreate(void); /// Checks if the dialect registry is null. static inline bool mlirDialectRegistryIsNull(MlirDialectRegistry registry) { @@ -363,7 +364,7 @@ /// Creates new printing flags with defaults, intended for customization. /// Must be freed with a call to mlirOpPrintingFlagsDestroy(). -MLIR_CAPI_EXPORTED MlirOpPrintingFlags mlirOpPrintingFlagsCreate(); +MLIR_CAPI_EXPORTED MlirOpPrintingFlags mlirOpPrintingFlagsCreate(void); /// Destroys printing flags created with mlirOpPrintingFlagsCreate. MLIR_CAPI_EXPORTED void mlirOpPrintingFlagsDestroy(MlirOpPrintingFlags flags); @@ -551,7 +552,7 @@ //===----------------------------------------------------------------------===// /// Creates a new empty region and transfers ownership to the caller. -MLIR_CAPI_EXPORTED MlirRegion mlirRegionCreate(); +MLIR_CAPI_EXPORTED MlirRegion mlirRegionCreate(void); /// Takes a region owned by the caller and destroys it. MLIR_CAPI_EXPORTED void mlirRegionDestroy(MlirRegion region); @@ -817,10 +818,11 @@ /// Returns the name of the attribute used to store symbol names compatible with /// symbol tables. -MLIR_CAPI_EXPORTED MlirStringRef mlirSymbolTableGetSymbolAttributeName(); +MLIR_CAPI_EXPORTED MlirStringRef mlirSymbolTableGetSymbolAttributeName(void); /// Returns the name of the attribute used to store symbol visibility. -MLIR_CAPI_EXPORTED MlirStringRef mlirSymbolTableGetVisibilityAttributeName(); +MLIR_CAPI_EXPORTED MlirStringRef +mlirSymbolTableGetVisibilityAttributeName(void); /// Creates a symbol table for the given operation. If the operation does not /// have the SymbolTable trait, returns a null symbol table. diff --git a/mlir/include/mlir-c/RegisterEverything.h b/mlir/include/mlir-c/RegisterEverything.h --- a/mlir/include/mlir-c/RegisterEverything.h +++ b/mlir/include/mlir-c/RegisterEverything.h @@ -29,7 +29,7 @@ MLIR_CAPI_EXPORTED void mlirRegisterAllLLVMTranslations(MlirContext context); /// Register all compiler passes of MLIR. -MLIR_CAPI_EXPORTED void mlirRegisterAllPasses(); +MLIR_CAPI_EXPORTED void mlirRegisterAllPasses(void); #ifdef __cplusplus } diff --git a/mlir/include/mlir-c/Support.h b/mlir/include/mlir-c/Support.h --- a/mlir/include/mlir-c/Support.h +++ b/mlir/include/mlir-c/Support.h @@ -127,13 +127,13 @@ } /// Creates a logical result representing a success. -inline static MlirLogicalResult mlirLogicalResultSuccess() { +inline static MlirLogicalResult mlirLogicalResultSuccess(void) { MlirLogicalResult res = {1}; return res; } /// Creates a logical result representing a failure. -inline static MlirLogicalResult mlirLogicalResultFailure() { +inline static MlirLogicalResult mlirLogicalResultFailure(void) { MlirLogicalResult res = {0}; return res; } @@ -160,7 +160,7 @@ //===----------------------------------------------------------------------===// /// Creates a type id allocator for dynamic type id creation -MLIR_CAPI_EXPORTED MlirTypeIDAllocator mlirTypeIDAllocatorCreate(); +MLIR_CAPI_EXPORTED MlirTypeIDAllocator mlirTypeIDAllocatorCreate(void); /// Deallocates the allocator and all allocated type ids MLIR_CAPI_EXPORTED void diff --git a/mlir/test/CAPI/execution_engine.c b/mlir/test/CAPI/execution_engine.c --- a/mlir/test/CAPI/execution_engine.c +++ b/mlir/test/CAPI/execution_engine.c @@ -46,7 +46,7 @@ } // CHECK-LABEL: Running test 'testSimpleExecution' -void testSimpleExecution() { +void testSimpleExecution(void) { MlirContext ctx = mlirContextCreate(); registerAllUpstreamDialects(ctx); @@ -84,7 +84,7 @@ mlirContextDestroy(ctx); } -int main() { +int main(void) { #define _STRINGIFY(x) #x #define STRINGIFY(x) _STRINGIFY(x) diff --git a/mlir/test/CAPI/ir.c b/mlir/test/CAPI/ir.c --- a/mlir/test/CAPI/ir.c +++ b/mlir/test/CAPI/ir.c @@ -1616,7 +1616,7 @@ return 0; } -int registerOnlyStd() { +int registerOnlyStd(void) { MlirContext ctx = mlirContextCreate(); // The built-in dialect is always loaded. if (mlirContextGetNumLoadedDialects(ctx) != 1) @@ -1670,7 +1670,7 @@ } /// Tests backreference APIs -static int testBackreferences() { +static int testBackreferences(void) { fprintf(stderr, "@test_backreferences\n"); MlirContext ctx = mlirContextCreate(); @@ -1708,7 +1708,7 @@ } /// Tests operand APIs. -int testOperands() { +int testOperands(void) { fprintf(stderr, "@testOperands\n"); // CHECK-LABEL: @testOperands @@ -1778,7 +1778,7 @@ } /// Tests clone APIs. -int testClone() { +int testClone(void) { fprintf(stderr, "@testClone\n"); // CHECK-LABEL: @testClone @@ -2023,7 +2023,7 @@ return 0; } -int testDialectRegistry() { +int testDialectRegistry(void) { fprintf(stderr, "@testDialectRegistry\n"); MlirDialectRegistry registry = mlirDialectRegistryCreate(); @@ -2053,7 +2053,7 @@ return 0; } -void testDiagnostics() { +void testDiagnostics(void) { MlirContext ctx = mlirContextCreate(); MlirDiagnosticHandlerID id = mlirContextAttachDiagnosticHandler( ctx, errorHandler, (void *)42, deleteUserData); @@ -2104,7 +2104,7 @@ mlirContextDestroy(ctx); } -int main() { +int main(void) { MlirContext ctx = mlirContextCreate(); registerAllUpstreamDialects(ctx); mlirContextGetOrLoadDialect(ctx, mlirStringRefCreateFromCString("func")); diff --git a/mlir/test/CAPI/llvm.c b/mlir/test/CAPI/llvm.c --- a/mlir/test/CAPI/llvm.c +++ b/mlir/test/CAPI/llvm.c @@ -70,7 +70,7 @@ mlirTypeEqual(i32_i64_s, i32_i64_s_ref)); } -int main() { +int main(void) { MlirContext ctx = mlirContextCreate(); mlirDialectHandleRegisterDialect(mlirGetDialectHandle__llvm__(), ctx); mlirContextGetOrLoadDialect(ctx, mlirStringRefCreateFromCString("llvm")); diff --git a/mlir/test/CAPI/pass.c b/mlir/test/CAPI/pass.c --- a/mlir/test/CAPI/pass.c +++ b/mlir/test/CAPI/pass.c @@ -29,7 +29,7 @@ mlirDialectRegistryDestroy(registry); } -void testRunPassOnModule() { +void testRunPassOnModule(void) { MlirContext ctx = mlirContextCreate(); registerAllUpstreamDialects(ctx); @@ -67,7 +67,7 @@ mlirContextDestroy(ctx); } -void testRunPassOnNestedModule() { +void testRunPassOnNestedModule(void) { MlirContext ctx = mlirContextCreate(); registerAllUpstreamDialects(ctx); @@ -138,7 +138,7 @@ (void)userData; } -void testPrintPassPipeline() { +void testPrintPassPipeline(void) { MlirContext ctx = mlirContextCreate(); MlirPassManager pm = mlirPassManagerCreateOnOperation( ctx, mlirStringRefCreateFromCString("any")); @@ -175,7 +175,7 @@ mlirContextDestroy(ctx); } -void testParsePassPipeline() { +void testParsePassPipeline(void) { MlirContext ctx = mlirContextCreate(); MlirPassManager pm = mlirPassManagerCreate(ctx); // Try parse a pipeline. @@ -233,7 +233,7 @@ mlirContextDestroy(ctx); } -void testParseErrorCapture() { +void testParseErrorCapture(void) { // CHECK-LABEL: testParseErrorCapture: fprintf(stderr, "\nTEST: testParseErrorCapture:\n"); @@ -335,7 +335,7 @@ testCloneExternalPass, runPass}; } -void testExternalPass() { +void testExternalPass(void) { MlirContext ctx = mlirContextCreate(); registerAllUpstreamDialects(ctx); @@ -591,7 +591,7 @@ mlirContextDestroy(ctx); } -int main() { +int main(void) { testRunPassOnModule(); testRunPassOnNestedModule(); testPrintPassPipeline(); diff --git a/mlir/test/CAPI/pdl.c b/mlir/test/CAPI/pdl.c --- a/mlir/test/CAPI/pdl.c +++ b/mlir/test/CAPI/pdl.c @@ -325,7 +325,7 @@ fprintf(stderr, "\n\n"); } -int main() { +int main(void) { MlirContext ctx = mlirContextCreate(); mlirDialectHandleRegisterDialect(mlirGetDialectHandle__pdl__(), ctx); testAttributeType(ctx); diff --git a/mlir/test/CAPI/quant.c b/mlir/test/CAPI/quant.c --- a/mlir/test/CAPI/quant.c +++ b/mlir/test/CAPI/quant.c @@ -226,7 +226,7 @@ fprintf(stderr, "\n\n"); } -int main() { +int main(void) { MlirContext ctx = mlirContextCreate(); mlirDialectHandleRegisterDialect(mlirGetDialectHandle__quant__(), ctx); testTypeHierarchy(ctx); diff --git a/mlir/test/CAPI/sparse_tensor.c b/mlir/test/CAPI/sparse_tensor.c --- a/mlir/test/CAPI/sparse_tensor.c +++ b/mlir/test/CAPI/sparse_tensor.c @@ -74,7 +74,7 @@ return 0; } -int main() { +int main(void) { MlirContext ctx = mlirContextCreate(); mlirDialectHandleRegisterDialect(mlirGetDialectHandle__sparse_tensor__(), ctx); diff --git a/mlir/tools/mlir-tblgen/PassCAPIGen.cpp b/mlir/tools/mlir-tblgen/PassCAPIGen.cpp --- a/mlir/tools/mlir-tblgen/PassCAPIGen.cpp +++ b/mlir/tools/mlir-tblgen/PassCAPIGen.cpp @@ -32,8 +32,8 @@ const char *const passDecl = R"( /* Create {0} Pass. */ -MLIR_CAPI_EXPORTED MlirPass mlirCreate{0}{1}(); -MLIR_CAPI_EXPORTED void mlirRegister{0}{1}(); +MLIR_CAPI_EXPORTED MlirPass mlirCreate{0}{1}(void); +MLIR_CAPI_EXPORTED void mlirRegister{0}{1}(void); )"; @@ -59,7 +59,8 @@ static bool emitCAPIHeader(const llvm::RecordKeeper &records, raw_ostream &os) { os << fileHeader; os << "// Registration for the entire group\n"; - os << "MLIR_CAPI_EXPORTED void mlirRegister" << groupName << "Passes();\n\n"; + os << "MLIR_CAPI_EXPORTED void mlirRegister" << groupName + << "Passes(void);\n\n"; for (const auto *def : records.getAllDerivedDefinitions("PassBase")) { Pass pass(def); StringRef defName = pass.getDef()->getName(); @@ -70,10 +71,10 @@ } const char *const passCreateDef = R"( -MlirPass mlirCreate{0}{1}() { +MlirPass mlirCreate{0}{1}(void) { return wrap({2}.release()); } -void mlirRegister{0}{1}() { +void mlirRegister{0}{1}(void) { register{1}(); } @@ -85,7 +86,7 @@ // {0} Group Registration //===----------------------------------------------------------------------===// -void mlirRegister{0}Passes() {{ +void mlirRegister{0}Passes(void) {{ register{0}Passes(); } )";