Skip to content

Commit 2b81002

Browse files
avoid variable length array
1 parent 2a5c211 commit 2b81002

File tree

2 files changed

+4
-8
lines changed

2 files changed

+4
-8
lines changed

lib/Interpreter/CMakeLists.txt

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,3 @@ string(REPLACE ";" "\;" _VER CPPINTEROP_VERSION)
141141
set_source_files_properties(CppInterOp.cpp PROPERTIES COMPILE_DEFINITIONS
142142
"LLVM_BINARY_DIR=\"${LLVM_BINARY_DIR}\";CPPINTEROP_VERSION=\"${_VAR}\""
143143
)
144-
145-
if(NOT WIN32)
146-
set_source_files_properties(CppInterOp.cpp PROPERTIES
147-
COMPILE_FLAGS "-Wno-vla"
148-
)
149-
endif()

lib/Interpreter/CppInterOp.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1075,7 +1075,7 @@ namespace Cpp {
10751075
struct WrapperExpr : public OpaqueValueExpr {
10761076
WrapperExpr() : OpaqueValueExpr(clang::Stmt::EmptyShell()) {}
10771077
};
1078-
WrapperExpr Exprs[arg_types.size()];
1078+
auto* Exprs = new WrapperExpr[arg_types.size()];
10791079
llvm::SmallVector<Expr*> Args;
10801080
Args.reserve(arg_types.size());
10811081
size_t idx = 0;
@@ -1135,7 +1135,9 @@ namespace Cpp {
11351135
OverloadCandidateSet::iterator Best;
11361136
Overloads.BestViableFunction(S, SourceLocation(), Best);
11371137

1138-
return Best != Overloads.end() ? Best->Function : nullptr;
1138+
FunctionDecl* Result = Best != Overloads.end() ? Best->Function : nullptr;
1139+
delete[] Exprs;
1140+
return Result;
11391141
}
11401142

11411143
// Gets the AccessSpecifier of the function and checks if it is equal to

0 commit comments

Comments
 (0)