Explicitly compile with warnings-as-errors

This is a partial revert of https://swiftshader-review.googlesource.com/c/SwiftShader/+/40788
where .c files were renamed to .cpp to avoid a warning treated as error:
command line option ‘-fno-operator-names’ is valid for C++/ObjC++ but not for C [-Werror]
This appears to have caused macOS linker issues: chromium:1059196

Instead, explicitly add the flag to compile with warnings-as-errors
(when enabled) for code that is actively maintained by us, and make
Subzero's legacy LLVM dependencies a separate library compiled without
warnings-as-errors.

Also revert CMakeSettings.json changes that were inadvertently committed.

Bug: b/141361933
Bug: chromium:1059196
Change-Id: I27dd57d954a413a710613b0bfa2e69bd5242853a
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/41968
Reviewed-by: Marc-Antoine Desroches <madesroches@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
diff --git a/CMakeLists.txt b/CMakeLists.txt
index aa835b1..7deb25f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -377,12 +377,6 @@
     set_cpp_flag("/DEBUG:FASTLINK" DEBUG)
     set_cpp_flag("/DEBUG:FASTLINK" RELWITHDEBINFO)
 
-    if(SWIFTSHADER_WARNINGS_AS_ERRORS)
-        list(APPEND SWIFTSHADER_COMPILE_OPTIONS
-            "/WX" # Treat all warnings as errors
-        )
-    endif()
-
     # Disable specific warnings
     # TODO: Not all of these should be disabled, but for now, we want a warning-free msvc build. Remove these one by one
     #       and fix the actual warnings in code.
@@ -511,10 +505,6 @@
         set_cpp_flag("-s" RELEASE)
     endif()
 
-    if(SWIFTSHADER_WARNINGS_AS_ERRORS)
-        list(APPEND SWIFTSHADER_COMPILE_OPTIONS "-Werror") # Treat all warnings as errors
-    endif()
-
     if(SWIFTSHADER_DCHECK_ALWAYS_ON)
         list(APPEND SWIFTSHADER_COMPILE_OPTIONS "-DDCHECK_ALWAYS_ON")
     endif()
@@ -549,6 +539,14 @@
     endif()
 endif()
 
+if(SWIFTSHADER_WARNINGS_AS_ERRORS)
+    if(MSVC)
+        set(WARNINGS_AS_ERRORS "/WX")  # Treat all warnings as errors
+    else()
+        set(WARNINGS_AS_ERRORS "-Werror")  # Treat all warnings as errors
+    endif()
+endif()
+
 if(REACTOR_EMIT_PRINT_LOCATION)
     # This feature depends on REACTOR_EMIT_DEBUG_INFO and REACTOR_ENABLE_PRINT
     set(REACTOR_EMIT_DEBUG_INFO "On")
@@ -1625,6 +1623,7 @@
 
     file(GLOB_RECURSE SUBZERO_DEPENDENCIES_LIST
         ${SUBZERO_LLVM_DIR}/*.cpp
+        ${SUBZERO_LLVM_DIR}/*.c
         ${SUBZERO_LLVM_DIR}/*.h
     )
 
@@ -1667,18 +1666,28 @@
         )
     endif()
 
+    add_library(SubzeroDependencies STATIC
+        ${SUBZERO_DEPENDENCIES_LIST}
+    )
+    set_target_properties(SubzeroDependencies PROPERTIES
+        POSITION_INDEPENDENT_CODE 1
+        INCLUDE_DIRECTORIES "${SUBZERO_INCLUDE_DIR}"
+        COMPILE_OPTIONS "${SUBZERO_COMPILE_OPTIONS}"
+        FOLDER "Subzero"
+    )
+
     add_library(ReactorSubzero STATIC
         ${SUBZERO_LIST}
-        ${SUBZERO_DEPENDENCIES_LIST}
         ${SUBZERO_REACTOR_LIST}
     )
     set_target_properties(ReactorSubzero PROPERTIES
         POSITION_INDEPENDENT_CODE 1
         INCLUDE_DIRECTORIES "${SUBZERO_INCLUDE_DIR}"
-        COMPILE_OPTIONS "${SUBZERO_COMPILE_OPTIONS};${SWIFTSHADER_COMPILE_OPTIONS}"
+        COMPILE_OPTIONS "${SUBZERO_COMPILE_OPTIONS};${SWIFTSHADER_COMPILE_OPTIONS};${WARNINGS_AS_ERRORS}"
         COMPILE_DEFINITIONS "SZTARGET=${SUBZERO_TARGET}; ALLOW_DUMP=0; ALLOW_TIMERS=0; ALLOW_LLVM_CL=0; ALLOW_LLVM_IR=0; ALLOW_LLVM_IR_AS_INPUT=0; ALLOW_MINIMAL_BUILD=0; ALLOW_WASM=0; ICE_THREAD_LOCAL_HACK=0;"
         FOLDER "Subzero"
     )
+    target_link_libraries(ReactorSubzero SubzeroDependencies)
 
     if(WIN32)
         target_compile_definitions(ReactorSubzero PRIVATE SUBZERO_USE_MICROSOFT_ABI)
@@ -2000,7 +2009,7 @@
     INCLUDE_DIRECTORIES "${COMMON_INCLUDE_DIR}"
     POSITION_INDEPENDENT_CODE 1
     FOLDER "Core"
-    COMPILE_OPTIONS "${SWIFTSHADER_COMPILE_OPTIONS}"
+    COMPILE_OPTIONS "${SWIFTSHADER_COMPILE_OPTIONS};${WARNINGS_AS_ERRORS}"
     COMPILE_DEFINITIONS "NO_SANITIZE_FUNCTION=;"
 )
 target_link_libraries(SwiftShader ${OS_LIBS})
@@ -2011,7 +2020,7 @@
         INCLUDE_DIRECTORIES "${COMMON_INCLUDE_DIR}"
         POSITION_INDEPENDENT_CODE 1
         FOLDER "Core"
-        COMPILE_OPTIONS "${SWIFTSHADER_COMPILE_OPTIONS}"
+        COMPILE_OPTIONS "${SWIFTSHADER_COMPILE_OPTIONS};${WARNINGS_AS_ERRORS}"
     )
     target_link_libraries(ReactorLLVM llvm ${OS_LIBS})
     set(Reactor ReactorLLVM)
@@ -2056,7 +2065,7 @@
     INCLUDE_DIRECTORIES "${OPENGL_INCLUDE_DIR}"
     POSITION_INDEPENDENT_CODE 1
     FOLDER "OpenGL"
-    COMPILE_OPTIONS "${SWIFTSHADER_COMPILE_OPTIONS}"
+    COMPILE_OPTIONS "${SWIFTSHADER_COMPILE_OPTIONS};${WARNINGS_AS_ERRORS}"
 )
 target_link_libraries(GLCompiler ${OS_LIBS})
 
@@ -2071,7 +2080,7 @@
     set_target_properties(libEGL PROPERTIES
         INCLUDE_DIRECTORIES "${OPENGL_INCLUDE_DIR}"
         FOLDER "OpenGL"
-        COMPILE_OPTIONS "${SWIFTSHADER_COMPILE_OPTIONS}"
+        COMPILE_OPTIONS "${SWIFTSHADER_COMPILE_OPTIONS};${WARNINGS_AS_ERRORS}"
         COMPILE_DEFINITIONS "EGL_EGLEXT_PROTOTYPES; EGLAPI=; NO_SANITIZE_FUNCTION=;$<$<CONFIG:Debug>:DEBUGGER_WAIT_DIALOG>"
         PREFIX ""
     )
@@ -2100,7 +2109,7 @@
     set_target_properties(libGLESv2 PROPERTIES
         INCLUDE_DIRECTORIES "${OPENGL_INCLUDE_DIR}"
         FOLDER "OpenGL"
-        COMPILE_OPTIONS "${SWIFTSHADER_COMPILE_OPTIONS}"
+        COMPILE_OPTIONS "${SWIFTSHADER_COMPILE_OPTIONS};${WARNINGS_AS_ERRORS}"
         COMPILE_DEFINITIONS "GL_GLEXT_PROTOTYPES; GL_API=; GL_APICALL=; GLAPI=; NO_SANITIZE_FUNCTION=;"
         PREFIX ""
     )
@@ -2124,7 +2133,7 @@
     set_target_properties(libGLES_CM PROPERTIES
         INCLUDE_DIRECTORIES "${OPENGL_INCLUDE_DIR}"
         FOLDER "OpenGL"
-        COMPILE_OPTIONS "${SWIFTSHADER_COMPILE_OPTIONS}"
+        COMPILE_OPTIONS "${SWIFTSHADER_COMPILE_OPTIONS};${WARNINGS_AS_ERRORS}"
         COMPILE_DEFINITIONS "GL_GLEXT_PROTOTYPES; EGLAPI=; GL_API=; GL_APICALL=; GLAPI=;"
         PREFIX ""
     )
@@ -2186,7 +2195,7 @@
     set_target_properties(vk_swiftshader PROPERTIES
         INCLUDE_DIRECTORIES "${VULKAN_INCLUDE_DIR}"
         FOLDER "Vulkan"
-        COMPILE_OPTIONS "${SWIFTSHADER_COMPILE_OPTIONS}"
+        COMPILE_OPTIONS "${SWIFTSHADER_COMPILE_OPTIONS};${WARNINGS_AS_ERRORS}"
         COMPILE_DEFINITIONS "VK_EXPORT=;NO_SANITIZE_FUNCTION=;$<$<CONFIG:Debug>:DEBUGGER_WAIT_DIALOG>"
     )
 
@@ -2301,7 +2310,7 @@
     add_executable(ReactorUnitTests ${REACTOR_UNIT_TESTS_LIST})
     set_target_properties(ReactorUnitTests PROPERTIES
         INCLUDE_DIRECTORIES "${REACTOR_UNIT_TESTS_INCLUDE_DIR}"
-        COMPILE_OPTIONS "${SWIFTSHADER_COMPILE_OPTIONS}"
+        COMPILE_OPTIONS "${SWIFTSHADER_COMPILE_OPTIONS};${WARNINGS_AS_ERRORS}"
         FOLDER "Tests"
     )
 
@@ -2328,7 +2337,7 @@
     set_target_properties(gles-unittests PROPERTIES
         INCLUDE_DIRECTORIES "${GLES_UNITTESTS_INCLUDE_DIR}"
         FOLDER "Tests"
-        COMPILE_OPTIONS "${SWIFTSHADER_COMPILE_OPTIONS}"
+        COMPILE_OPTIONS "${SWIFTSHADER_COMPILE_OPTIONS};${WARNINGS_AS_ERRORS}"
         COMPILE_DEFINITIONS "STANDALONE"
     )
 
@@ -2355,7 +2364,7 @@
     set_target_properties(math-unittests PROPERTIES
         INCLUDE_DIRECTORIES "${MATH_UNITTESTS_INCLUDE_DIR}"
         FOLDER "Tests"
-        COMPILE_OPTIONS "${SWIFTSHADER_COMPILE_OPTIONS}"
+        COMPILE_OPTIONS "${SWIFTSHADER_COMPILE_OPTIONS};${WARNINGS_AS_ERRORS}"
     )
 
     if(NOT WIN32)
@@ -2377,7 +2386,7 @@
     target_link_libraries(ReactorBenchmarks benchmark::benchmark ${Reactor})
 
     set_target_properties(ReactorBenchmarks PROPERTIES
-        COMPILE_OPTIONS "${SWIFTSHADER_COMPILE_OPTIONS}"
+        COMPILE_OPTIONS "${SWIFTSHADER_COMPILE_OPTIONS};${WARNINGS_AS_ERRORS}"
         FOLDER "Benchmarks"
     )
 endif(SWIFTSHADER_BUILD_BENCHMARKS)
@@ -2405,7 +2414,7 @@
     set_target_properties(vk-unittests PROPERTIES
         INCLUDE_DIRECTORIES "${VK_UNITTESTS_INCLUDE_DIR}"
         FOLDER "Tests"
-        COMPILE_OPTIONS "${SWIFTSHADER_COMPILE_OPTIONS}"
+        COMPILE_OPTIONS "${SWIFTSHADER_COMPILE_OPTIONS};${WARNINGS_AS_ERRORS}"
         COMPILE_DEFINITIONS "STANDALONE"
     )
 
diff --git a/CMakeSettings.json b/CMakeSettings.json
index ef9b5f5..c3d2919 100644
--- a/CMakeSettings.json
+++ b/CMakeSettings.json
@@ -1,69 +1,52 @@
-{

-  "configurations": [

-    {

-      "name": "x64-Debug",

-      "generator": "Ninja",

-      "configurationType": "Debug",

-      "inheritEnvironments": [ "msvc_x64_x64" ],

-      "buildRoot": "${projectDir}\\out\\build\\${name}",

-      "installRoot": "${projectDir}\\out\\install\\${name}",

-      "cmakeCommandArgs": "",

-      "buildCommandArgs": "-v",

-      "ctestCommandArgs": "",

-      "variables": [

-        {

-          "name": "REACTOR_BACKEND",

-          "value": "Subzero",

-          "type": "STRING"

-        }

-      ]

-    },

-    {

-      "name": "x86-Debug",

-      "generator": "Ninja",

-      "configurationType": "Debug",

-      "buildRoot": "${projectDir}\\out\\build\\${name}",

-      "installRoot": "${projectDir}\\out\\install\\${name}",

-      "cmakeCommandArgs": "",

-      "buildCommandArgs": "-v",

-      "ctestCommandArgs": "",

-      "inheritEnvironments": [ "msvc_x86" ],

-      "variables": []

-    },

-    {

-      "name": "x86-Release",

-      "generator": "Ninja",

-      "configurationType": "RelWithDebInfo",

-      "buildRoot": "${projectDir}\\out\\build\\${name}",

-      "installRoot": "${projectDir}\\out\\install\\${name}",

-      "cmakeCommandArgs": "",

-      "buildCommandArgs": "-v",

-      "ctestCommandArgs": "",

-      "inheritEnvironments": [ "msvc_x86" ],

-      "variables": []

-    },

-    {

-      "name": "x64-Release",

-      "generator": "Ninja",

-      "configurationType": "RelWithDebInfo",

-      "buildRoot": "${projectDir}\\out\\build\\${name}",

-      "installRoot": "${projectDir}\\out\\install\\${name}",

-      "cmakeCommandArgs": "",

-      "buildCommandArgs": "-v",

-      "ctestCommandArgs": "",

-      "inheritEnvironments": [ "msvc_x64_x64" ],

-      "variables": [

-        {

-          "name": "SWIFTSHADER_BUILD_PVR",

-          "value": "True",

-          "type": "BOOL"

-        },

-        {

-          "name": "REACTOR_BACKEND",

-          "value": "Subzero",

-          "type": "STRING"

-        }

-      ]

-    }

-  ]

+{
+  "configurations": [
+    {
+      "name": "x64-Debug",
+      "generator": "Ninja",
+      "configurationType": "Debug",
+      "inheritEnvironments": [ "msvc_x64_x64" ],
+      "buildRoot": "${projectDir}\\out\\build\\${name}",
+      "installRoot": "${projectDir}\\out\\install\\${name}",
+      "cmakeCommandArgs": "",
+      "buildCommandArgs": "-v",
+      "ctestCommandArgs": "",
+      "variables": []
+    },
+    {
+      "name": "x86-Debug",
+      "generator": "Ninja",
+      "configurationType": "Debug",
+      "buildRoot": "${projectDir}\\out\\build\\${name}",
+      "installRoot": "${projectDir}\\out\\install\\${name}",
+      "cmakeCommandArgs": "",
+      "buildCommandArgs": "-v",
+      "ctestCommandArgs": "",
+      "inheritEnvironments": [ "msvc_x86" ],
+      "variables": []
+    },
+    {
+      "name": "x86-Release",
+      "generator": "Ninja",
+      "configurationType": "RelWithDebInfo",
+      "buildRoot": "${projectDir}\\out\\build\\${name}",
+      "installRoot": "${projectDir}\\out\\install\\${name}",
+      "cmakeCommandArgs": "",
+      "buildCommandArgs": "-v",
+      "ctestCommandArgs": "",
+      "inheritEnvironments": [ "msvc_x86" ],
+      "variables": []
+    },
+    {
+      "name": "x64-Release",
+      "generator": "Ninja",
+      "configurationType": "RelWithDebInfo",
+      "buildRoot": "${projectDir}\\out\\build\\${name}",
+      "installRoot": "${projectDir}\\out\\install\\${name}",
+      "cmakeCommandArgs": "",
+      "buildCommandArgs": "-v",
+      "ctestCommandArgs": "",
+      "inheritEnvironments": [ "msvc_x64_x64" ],
+      "variables": []
+    }
+  ]
 }
\ No newline at end of file
diff --git a/src/Reactor/BUILD.gn b/src/Reactor/BUILD.gn
index 3c2161e..66b4bf1 100644
--- a/src/Reactor/BUILD.gn
+++ b/src/Reactor/BUILD.gn
@@ -265,11 +265,11 @@
       "$subzero_llvm_dir/lib/Support/circular_raw_ostream.cpp",
       "$subzero_llvm_dir/lib/Support/raw_os_ostream.cpp",
       "$subzero_llvm_dir/lib/Support/raw_ostream.cpp",
-      "$subzero_llvm_dir/lib/Support/regcomp.cpp",
-      "$subzero_llvm_dir/lib/Support/regerror.cpp",
-      "$subzero_llvm_dir/lib/Support/regexec.cpp",
-      "$subzero_llvm_dir/lib/Support/regfree.cpp",
-      "$subzero_llvm_dir/lib/Support/regstrlcpy.cpp",
+      "$subzero_llvm_dir/lib/Support/regcomp.c",
+      "$subzero_llvm_dir/lib/Support/regerror.c",
+      "$subzero_llvm_dir/lib/Support/regexec.c",
+      "$subzero_llvm_dir/lib/Support/regfree.c",
+      "$subzero_llvm_dir/lib/Support/regstrlcpy.c",
     ]
 
     if (current_cpu == "x64") {
diff --git a/src/Reactor/SubzeroLLVMDependencies.vcxproj b/src/Reactor/SubzeroLLVMDependencies.vcxproj
index a66b3b2..38d7598 100644
--- a/src/Reactor/SubzeroLLVMDependencies.vcxproj
+++ b/src/Reactor/SubzeroLLVMDependencies.vcxproj
@@ -174,12 +174,12 @@
     <ClCompile Include="..\..\third_party\llvm-subzero\lib\Support\Program.cpp" />

     <ClCompile Include="..\..\third_party\llvm-subzero\lib\Support\raw_ostream.cpp" />

     <ClCompile Include="..\..\third_party\llvm-subzero\lib\Support\raw_os_ostream.cpp" />

-    <ClCompile Include="..\..\third_party\llvm-subzero\lib\Support\regcomp.cpp" />

-    <ClCompile Include="..\..\third_party\llvm-subzero\lib\Support\regerror.cpp" />

+    <ClCompile Include="..\..\third_party\llvm-subzero\lib\Support\regcomp.c" />

+    <ClCompile Include="..\..\third_party\llvm-subzero\lib\Support\regerror.c" />

     <ClCompile Include="..\..\third_party\llvm-subzero\lib\Support\Regex.cpp" />

-    <ClCompile Include="..\..\third_party\llvm-subzero\lib\Support\regexec.cpp" />

-    <ClCompile Include="..\..\third_party\llvm-subzero\lib\Support\regfree.cpp" />

-    <ClCompile Include="..\..\third_party\llvm-subzero\lib\Support\regstrlcpy.cpp" />

+    <ClCompile Include="..\..\third_party\llvm-subzero\lib\Support\regexec.c" />

+    <ClCompile Include="..\..\third_party\llvm-subzero\lib\Support\regfree.c" />

+    <ClCompile Include="..\..\third_party\llvm-subzero\lib\Support\regstrlcpy.c" />

     <ClCompile Include="..\..\third_party\llvm-subzero\lib\Support\Signals.cpp" />

     <ClCompile Include="..\..\third_party\llvm-subzero\lib\Support\SmallPtrSet.cpp" />

     <ClCompile Include="..\..\third_party\llvm-subzero\lib\Support\SmallVector.cpp" />

diff --git a/src/Reactor/SubzeroLLVMDependencies.vcxproj.filters b/src/Reactor/SubzeroLLVMDependencies.vcxproj.filters
index 4f977de..d3d84e6 100644
--- a/src/Reactor/SubzeroLLVMDependencies.vcxproj.filters
+++ b/src/Reactor/SubzeroLLVMDependencies.vcxproj.filters
@@ -138,19 +138,19 @@
     <ClCompile Include="..\..\third_party\llvm-subzero\lib\Support\NativeFormatting.cpp">

       <Filter>Source Files\Support</Filter>

     </ClCompile>

-    <ClCompile Include="..\..\third_party\llvm-subzero\lib\Support\regerror.cpp">

+    <ClCompile Include="..\..\third_party\llvm-subzero\lib\Support\regerror.c">

       <Filter>Source Files\Support</Filter>

     </ClCompile>

-    <ClCompile Include="..\..\third_party\llvm-subzero\lib\Support\regfree.cpp">

+    <ClCompile Include="..\..\third_party\llvm-subzero\lib\Support\regfree.c">

       <Filter>Source Files\Support</Filter>

     </ClCompile>

-    <ClCompile Include="..\..\third_party\llvm-subzero\lib\Support\regstrlcpy.cpp">

+    <ClCompile Include="..\..\third_party\llvm-subzero\lib\Support\regstrlcpy.c">

       <Filter>Source Files\Support</Filter>

     </ClCompile>

-    <ClCompile Include="..\..\third_party\llvm-subzero\lib\Support\regcomp.cpp">

+    <ClCompile Include="..\..\third_party\llvm-subzero\lib\Support\regcomp.c">

       <Filter>Source Files\Support</Filter>

     </ClCompile>

-    <ClCompile Include="..\..\third_party\llvm-subzero\lib\Support\regexec.cpp">

+    <ClCompile Include="..\..\third_party\llvm-subzero\lib\Support\regexec.c">

       <Filter>Source Files\Support</Filter>

     </ClCompile>

   </ItemGroup>

diff --git a/third_party/llvm-subzero/Android.bp b/third_party/llvm-subzero/Android.bp
index a8c3c4b..72c9b32 100644
--- a/third_party/llvm-subzero/Android.bp
+++ b/third_party/llvm-subzero/Android.bp
@@ -59,12 +59,12 @@
         "lib/Support/Program.cpp",
         "lib/Support/raw_os_ostream.cpp",
         "lib/Support/raw_ostream.cpp",
-        "lib/Support/regcomp.cpp",
-        "lib/Support/regerror.cpp",
+        "lib/Support/regcomp.c",
+        "lib/Support/regerror.c",
         "lib/Support/Regex.cpp",
-        "lib/Support/regexec.cpp",
-        "lib/Support/regfree.cpp",
-        "lib/Support/regstrlcpy.cpp",
+        "lib/Support/regexec.c",
+        "lib/Support/regfree.c",
+        "lib/Support/regstrlcpy.c",
         "lib/Support/Signals.cpp",
         "lib/Support/SmallPtrSet.cpp",
         "lib/Support/SmallVector.cpp",
diff --git a/third_party/llvm-subzero/lib/Support/regcomp.cpp b/third_party/llvm-subzero/lib/Support/regcomp.c
similarity index 99%
rename from third_party/llvm-subzero/lib/Support/regcomp.cpp
rename to third_party/llvm-subzero/lib/Support/regcomp.c
index 7967c6c..ebde64f 100644
--- a/third_party/llvm-subzero/lib/Support/regcomp.cpp
+++ b/third_party/llvm-subzero/lib/Support/regcomp.c
@@ -1085,12 +1085,12 @@
 		ptr = (cset *)realloc((char *)p->g->sets, nc * sizeof(cset));
 		if (ptr == NULL)
 			goto nomem;
-		p->g->sets = (cset *)ptr;
+		p->g->sets = ptr;
 
 		ptr = (uch *)realloc((char *)p->g->setbits, nbytes);
 		if (ptr == NULL)
 			goto nomem;
-		p->g->setbits = (uch *)ptr;
+		p->g->setbits = ptr;
 
 		for (i = 0; i < no; i++)
 			p->g->sets[i].ptr = p->g->setbits + css*(i/CHAR_BIT);
@@ -1223,7 +1223,7 @@
 		SETERROR(REG_ESPACE);
 		return;
 	}
-	cs->multis = (char *)np;
+	cs->multis = np;
 
 	llvm_strlcpy(cs->multis + oldend - 1, cp, cs->smultis - oldend + 1);
 }
@@ -1523,7 +1523,7 @@
 		return;
 
 	/* turn it into a character string */
-	g->must = (char *)malloc((size_t)g->mlen + 1);
+	g->must = malloc((size_t)g->mlen + 1);
 	if (g->must == NULL) {		/* argh; just forget it */
 		g->mlen = 0;
 		return;
diff --git a/third_party/llvm-subzero/lib/Support/regerror.cpp b/third_party/llvm-subzero/lib/Support/regerror.c
similarity index 100%
rename from third_party/llvm-subzero/lib/Support/regerror.cpp
rename to third_party/llvm-subzero/lib/Support/regerror.c
diff --git a/third_party/llvm-subzero/lib/Support/regexec.cpp b/third_party/llvm-subzero/lib/Support/regexec.c
similarity index 97%
rename from third_party/llvm-subzero/lib/Support/regexec.cpp
rename to third_party/llvm-subzero/lib/Support/regexec.c
index a4896dc..bd5e72d 100644
--- a/third_party/llvm-subzero/lib/Support/regexec.cpp
+++ b/third_party/llvm-subzero/lib/Support/regexec.c
@@ -111,7 +111,7 @@
 #define	ASSIGN(d, s)	memmove(d, s, m->g->nstates)
 #define	EQ(a, b)	(memcmp(a, b, m->g->nstates) == 0)
 #define	STATEVARS	long vn; char *space
-#define	STATESETUP(m, nv)	{ (m)->space = static_cast<decltype((m)->space)>(malloc((nv)*(m)->g->nstates)); \
+#define	STATESETUP(m, nv)	{ (m)->space = malloc((nv)*(m)->g->nstates); \
 				if ((m)->space == NULL) return(REG_ESPACE); \
 				(m)->vn = 0; }
 #define	STATETEARDOWN(m)	{ free((m)->space); }
diff --git a/third_party/llvm-subzero/lib/Support/regfree.cpp b/third_party/llvm-subzero/lib/Support/regfree.c
similarity index 100%
rename from third_party/llvm-subzero/lib/Support/regfree.cpp
rename to third_party/llvm-subzero/lib/Support/regfree.c
diff --git a/third_party/llvm-subzero/lib/Support/regstrlcpy.cpp b/third_party/llvm-subzero/lib/Support/regstrlcpy.c
similarity index 100%
rename from third_party/llvm-subzero/lib/Support/regstrlcpy.cpp
rename to third_party/llvm-subzero/lib/Support/regstrlcpy.c