Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(517)

Unified Diff: src/IceGlobalContext.cpp

Issue 296823013: Fix g++ -pedantic warnings (Closed) Base URL: https://gerrit.chromium.org/gerrit/p/native_client/pnacl-subzero.git@master
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Makefile ('k') | src/IceInst.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/IceGlobalContext.cpp
diff --git a/src/IceGlobalContext.cpp b/src/IceGlobalContext.cpp
index ab63b4cda6bd878b4bcc89fd0eae600fa92fcbb9..e47b67f62cafeb7fce8ddd4a557956ac1f0c5b37 100644
--- a/src/IceGlobalContext.cpp
+++ b/src/IceGlobalContext.cpp
@@ -99,9 +99,11 @@ IceString GlobalContext::mangleName(const IceString &Name) const {
return Name;
unsigned PrefixLength = getTestPrefix().length();
- char NameBase[1 + Name.length()];
+ llvm::OwningArrayPtr<char> NameBaseOwner(new char[1 + Name.length()]);
JF 2014/05/23 16:45:22 Ew. VLAs aren't that evil in this context... What
Jim Stichnoth 2014/05/23 18:26:45 I don't know what the maximum identifier length is
+ char *NameBase = NameBaseOwner.get();
const size_t BufLen = 30 + Name.length() + PrefixLength;
- char NewName[BufLen];
+ llvm::OwningArrayPtr<char> NewNameOwner(new char[BufLen]);
+ char *NewName = NewNameOwner.get();
uint32_t BaseLength = 0; // using uint32_t due to sscanf format string
int ItemsParsed = sscanf(Name.c_str(), "_ZN%s", NameBase);
@@ -128,8 +130,10 @@ IceString GlobalContext::mangleName(const IceString &Name) const {
// Transform _Z3barIabcExyz ==> _ZN6Prefix3barIabcEExyz
// ^^^^^^^^ ^
// (splice in "N6Prefix", and insert "E" after "3barIabcE")
- char OrigName[Name.length()];
- char OrigSuffix[Name.length()];
+ llvm::OwningArrayPtr<char> OrigNameOwner(new char[Name.length()]);
+ char *OrigName = OrigNameOwner.get();
+ llvm::OwningArrayPtr<char> OrigSuffixOwner(new char[Name.length()]);
+ char *OrigSuffix = OrigSuffixOwner.get();
uint32_t ActualBaseLength = BaseLength;
if (NameBase[ActualBaseLength] == 'I') {
++ActualBaseLength;
« no previous file with comments | « Makefile ('k') | src/IceInst.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698