summaryrefslogtreecommitdiffstats
path: root/clang/include/clang-c
diff options
context:
space:
mode:
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>2019-11-14 13:57:57 -0800
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>2019-11-19 13:18:43 -0800
commit8c48405069085a2c8b6b80816eda99e5dad31fc1 (patch)
treeaf6a315cb0f8eecea89547b692c07964b0238ba1 /clang/include/clang-c
parent3a8104a9ea3d88fb4d0ef17185e420c814757bfd (diff)
downloadbcm5719-llvm-8c48405069085a2c8b6b80816eda99e5dad31fc1.tar.gz
bcm5719-llvm-8c48405069085a2c8b6b80816eda99e5dad31fc1.zip
Wrap C APIs with pragmas enforcing -Werror=strict-prototypes
Force `-Werror=strict-prototypes` so that C API tests fail to compile if we add a non-prototype declaration. This should help avoid regressions like bddecba4b333f7772029b4937d2c34f9f2fda6ca was fixing. https://reviews.llvm.org/D70285 rdar://problem/57203137
Diffstat (limited to 'clang/include/clang-c')
-rw-r--r--clang/include/clang-c/BuildSystem.h11
-rw-r--r--clang/include/clang-c/CXCompilationDatabase.h12
-rw-r--r--clang/include/clang-c/CXErrorCode.h10
-rw-r--r--clang/include/clang-c/CXString.h10
-rw-r--r--clang/include/clang-c/Documentation.h10
-rw-r--r--clang/include/clang-c/ExternC.h39
-rw-r--r--clang/include/clang-c/FatalErrorHandler.h11
-rw-r--r--clang/include/clang-c/Index.h14
-rw-r--r--clang/include/clang-c/Platform.h11
9 files changed, 75 insertions, 53 deletions
diff --git a/clang/include/clang-c/BuildSystem.h b/clang/include/clang-c/BuildSystem.h
index 8f26a861171..4e9f6dee027 100644
--- a/clang/include/clang-c/BuildSystem.h
+++ b/clang/include/clang-c/BuildSystem.h
@@ -14,13 +14,12 @@
#ifndef LLVM_CLANG_C_BUILDSYSTEM_H
#define LLVM_CLANG_C_BUILDSYSTEM_H
-#include "clang-c/Platform.h"
#include "clang-c/CXErrorCode.h"
#include "clang-c/CXString.h"
+#include "clang-c/ExternC.h"
+#include "clang-c/Platform.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
+LLVM_CLANG_C_EXTERN_C_BEGIN
/**
* \defgroup BUILD_SYSTEM Build system utilities
@@ -148,9 +147,7 @@ CINDEX_LINKAGE void clang_ModuleMapDescriptor_dispose(CXModuleMapDescriptor);
* @}
*/
-#ifdef __cplusplus
-}
-#endif
+LLVM_CLANG_C_EXTERN_C_END
#endif /* CLANG_C_BUILD_SYSTEM_H */
diff --git a/clang/include/clang-c/CXCompilationDatabase.h b/clang/include/clang-c/CXCompilationDatabase.h
index 2669c1a792c..2b336e5464a 100644
--- a/clang/include/clang-c/CXCompilationDatabase.h
+++ b/clang/include/clang-c/CXCompilationDatabase.h
@@ -15,12 +15,11 @@
#ifndef LLVM_CLANG_C_CXCOMPILATIONDATABASE_H
#define LLVM_CLANG_C_CXCOMPILATIONDATABASE_H
-#include "clang-c/Platform.h"
#include "clang-c/CXString.h"
+#include "clang-c/ExternC.h"
+#include "clang-c/Platform.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
+LLVM_CLANG_C_EXTERN_C_BEGIN
/** \defgroup COMPILATIONDB CompilationDatabase functions
* \ingroup CINDEX
@@ -169,8 +168,7 @@ clang_CompileCommand_getMappedSourceContent(CXCompileCommand, unsigned I);
* @}
*/
-#ifdef __cplusplus
-}
-#endif
+LLVM_CLANG_C_EXTERN_C_END
+
#endif
diff --git a/clang/include/clang-c/CXErrorCode.h b/clang/include/clang-c/CXErrorCode.h
index fed195ec1f3..b3a0b9d66d5 100644
--- a/clang/include/clang-c/CXErrorCode.h
+++ b/clang/include/clang-c/CXErrorCode.h
@@ -14,11 +14,10 @@
#ifndef LLVM_CLANG_C_CXERRORCODE_H
#define LLVM_CLANG_C_CXERRORCODE_H
+#include "clang-c/ExternC.h"
#include "clang-c/Platform.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
+LLVM_CLANG_C_EXTERN_C_BEGIN
/**
* Error codes returned by libclang routines.
@@ -57,8 +56,7 @@ enum CXErrorCode {
CXError_ASTReadError = 4
};
-#ifdef __cplusplus
-}
-#endif
+LLVM_CLANG_C_EXTERN_C_END
+
#endif
diff --git a/clang/include/clang-c/CXString.h b/clang/include/clang-c/CXString.h
index 1eb3442ccb2..f117010c71a 100644
--- a/clang/include/clang-c/CXString.h
+++ b/clang/include/clang-c/CXString.h
@@ -14,11 +14,10 @@
#ifndef LLVM_CLANG_C_CXSTRING_H
#define LLVM_CLANG_C_CXSTRING_H
+#include "clang-c/ExternC.h"
#include "clang-c/Platform.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
+LLVM_CLANG_C_EXTERN_C_BEGIN
/**
* \defgroup CINDEX_STRING String manipulation routines
@@ -64,8 +63,7 @@ CINDEX_LINKAGE void clang_disposeStringSet(CXStringSet *set);
* @}
*/
-#ifdef __cplusplus
-}
-#endif
+LLVM_CLANG_C_EXTERN_C_END
+
#endif
diff --git a/clang/include/clang-c/Documentation.h b/clang/include/clang-c/Documentation.h
index 4af8c93a367..ad3dd3bc78b 100644
--- a/clang/include/clang-c/Documentation.h
+++ b/clang/include/clang-c/Documentation.h
@@ -15,11 +15,10 @@
#ifndef LLVM_CLANG_C_DOCUMENTATION_H
#define LLVM_CLANG_C_DOCUMENTATION_H
+#include "clang-c/ExternC.h"
#include "clang-c/Index.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
+LLVM_CLANG_C_EXTERN_C_BEGIN
/**
* \defgroup CINDEX_COMMENT Comment introspection
@@ -545,10 +544,7 @@ CINDEX_LINKAGE CXString clang_FullComment_getAsXML(CXComment Comment);
* @}
*/
-
-#ifdef __cplusplus
-}
-#endif
+LLVM_CLANG_C_EXTERN_C_END
#endif /* CLANG_C_DOCUMENTATION_H */
diff --git a/clang/include/clang-c/ExternC.h b/clang/include/clang-c/ExternC.h
new file mode 100644
index 00000000000..384f24d47b0
--- /dev/null
+++ b/clang/include/clang-c/ExternC.h
@@ -0,0 +1,39 @@
+/*===- clang-c/ExternC.h - Wrapper for 'extern "C"' ---------------*- C -*-===*\
+|* *|
+|* Part of the LLVM Project, under the Apache License v2.0 with LLVM *|
+|* Exceptions. *|
+|* See https://llvm.org/LICENSE.txt for license information. *|
+|* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception *|
+|* *|
+|*===----------------------------------------------------------------------===*|
+|* *|
+|* This file defines an 'extern "C"' wrapper. *|
+|* *|
+\*===----------------------------------------------------------------------===*/
+
+#ifndef LLVM_CLANG_C_EXTERN_C_H
+#define LLVM_CLANG_C_EXTERN_C_H
+
+#ifdef __clang__
+#define LLVM_CLANG_C_STRICT_PROTOTYPES_BEGIN \
+ _Pragma("clang diagnostic push") \
+ _Pragma("clang diagnostic error \"-Wstrict-prototypes\"")
+#define LLVM_CLANG_C_STRICT_PROTOTYPES_END _Pragma("clang diagnostic pop")
+#else
+#define LLVM_CLANG_C_STRICT_PROTOTYPES_BEGIN
+#define LLVM_CLANG_C_STRICT_PROTOTYPES_END
+#endif
+
+#ifdef __cplusplus
+#define LLVM_CLANG_C_EXTERN_C_BEGIN \
+ extern "C" { \
+ LLVM_CLANG_C_STRICT_PROTOTYPES_BEGIN
+#define LLVM_CLANG_C_EXTERN_C_END \
+ LLVM_CLANG_C_STRICT_PROTOTYPES_END \
+ }
+#else
+#define LLVM_CLANG_C_EXTERN_C_BEGIN LLVM_CLANG_C_STRICT_PROTOTYPES_BEGIN
+#define LLVM_CLANG_C_EXTERN_C_END LLVM_CLANG_C_STRICT_PROTOTYPES_END
+#endif
+
+#endif
diff --git a/clang/include/clang-c/FatalErrorHandler.h b/clang/include/clang-c/FatalErrorHandler.h
index ce8ff2cae73..22f34fa815c 100644
--- a/clang/include/clang-c/FatalErrorHandler.h
+++ b/clang/include/clang-c/FatalErrorHandler.h
@@ -10,9 +10,9 @@
#ifndef LLVM_CLANG_C_FATAL_ERROR_HANDLER_H
#define LLVM_CLANG_C_FATAL_ERROR_HANDLER_H
-#ifdef __cplusplus
-extern "C" {
-#endif
+#include "clang-c/ExternC.h"
+
+LLVM_CLANG_C_EXTERN_C_BEGIN
/**
* Installs error handler that prints error message to stderr and calls abort().
@@ -27,7 +27,6 @@ void clang_install_aborting_llvm_fatal_error_handler(void);
*/
void clang_uninstall_llvm_fatal_error_handler(void);
-#ifdef __cplusplus
-}
-#endif
+LLVM_CLANG_C_EXTERN_C_END
+
#endif
diff --git a/clang/include/clang-c/Index.h b/clang/include/clang-c/Index.h
index 438ee3698a1..5ff887ea5bc 100644
--- a/clang/include/clang-c/Index.h
+++ b/clang/include/clang-c/Index.h
@@ -18,10 +18,11 @@
#include <time.h>
-#include "clang-c/Platform.h"
+#include "clang-c/BuildSystem.h"
#include "clang-c/CXErrorCode.h"
#include "clang-c/CXString.h"
-#include "clang-c/BuildSystem.h"
+#include "clang-c/ExternC.h"
+#include "clang-c/Platform.h"
/**
* The version constants for the libclang API.
@@ -51,9 +52,7 @@
CINDEX_VERSION_MAJOR, \
CINDEX_VERSION_MINOR)
-#ifdef __cplusplus
-extern "C" {
-#endif
+LLVM_CLANG_C_EXTERN_C_BEGIN
/** \defgroup CINDEX libclang: C Interface to Clang
*
@@ -6774,7 +6773,6 @@ CINDEX_LINKAGE unsigned clang_Type_visitFields(CXType T,
* @}
*/
-#ifdef __cplusplus
-}
-#endif
+LLVM_CLANG_C_EXTERN_C_END
+
#endif
diff --git a/clang/include/clang-c/Platform.h b/clang/include/clang-c/Platform.h
index 5284b533253..3bb66bb0df4 100644
--- a/clang/include/clang-c/Platform.h
+++ b/clang/include/clang-c/Platform.h
@@ -14,9 +14,9 @@
#ifndef LLVM_CLANG_C_PLATFORM_H
#define LLVM_CLANG_C_PLATFORM_H
-#ifdef __cplusplus
-extern "C" {
-#endif
+#include "clang-c/ExternC.h"
+
+LLVM_CLANG_C_EXTERN_C_BEGIN
/* MSVC DLL import/export. */
#ifdef _MSC_VER
@@ -39,7 +39,6 @@ extern "C" {
#endif
#endif
-#ifdef __cplusplus
-}
-#endif
+LLVM_CLANG_C_EXTERN_C_END
+
#endif
OpenPOWER on IntegriCloud