Skip to content

Commit 173f1d2

Browse files
committedMay 16, 2017
Store _definingLine in character array
Store _definingLine in a character array, instead of storing a pointer to a string literal. This is to allow dynamic conversion of line numbers from ints to strings, and thereby support a DefineLine(int) overload of DefineLine(cons char *). Signed-off-by: Sajid Ahmed <Syed.Sajid.Ahmed23@ibm.com>
1 parent f1f39eb commit 173f1d2

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed
 

‎compiler/ilgen/MethodBuilder.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ MethodBuilder::MethodBuilder(TR::TypeDictionary *types, OMR::VirtualMachineState
8686
_cachedParameterTypes(0),
8787
_cachedSignature(0),
8888
_definingFile(""),
89-
_definingLine(""),
9089
_symbols(0),
9190
_newSymbolsAreTemps(false),
9291
_useBytecodeBuilders(false),
@@ -97,6 +96,9 @@ MethodBuilder::MethodBuilder(TR::TypeDictionary *types, OMR::VirtualMachineState
9796
_bytecodeWorklist(NULL),
9897
_bytecodeHasBeenInWorklist(NULL)
9998
{
99+
100+
_definingLine[0] = '\0';
101+
100102
REPLAY({
101103
std::fstream rpHpp("ReplayMethod.hpp",std::fstream::out);
102104
rpHpp << "#include \"ilgen/MethodBuilder.hpp\"" << std::endl;

‎compiler/ilgen/MethodBuilder.hpp

+8-2
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@
3030
#include <fstream>
3131
#include "ilgen/IlBuilder.hpp"
3232

33+
// Maximum length of _definingLine string (including null terminator)
34+
#define MAX_LINE_NUM_LEN 7
35+
3336
class TR_HashTabInt;
3437
class TR_HashTabString;
3538
class TR_BitVector;
@@ -97,7 +100,10 @@ class MethodBuilder : public TR::IlBuilder
97100
void AppendBuilder(TR::IlBuilder *b) { this->OMR::IlBuilder::AppendBuilder(b); }
98101

99102
void DefineFile(const char *file) { _definingFile = file; }
100-
void DefineLine(const char *line) { _definingLine = line; }
103+
void DefineLine(const char *line)
104+
{
105+
snprintf(_definingLine, MAX_LINE_NUM_LEN * sizeof(char), "%s", line);
106+
}
101107

102108
void DefineName(const char *name);
103109
void DefineParameter(const char *name, TR::IlType *type);
@@ -173,7 +179,7 @@ class MethodBuilder : public TR::IlBuilder
173179
TR::IlType ** _cachedParameterTypes;
174180
char * _cachedSignature;
175181
const char * _definingFile;
176-
const char * _definingLine;
182+
char _definingLine[MAX_LINE_NUM_LEN];
177183
TR::IlType * _cachedParameterTypesArray[10];
178184
char _cachedSignatureArray[100];
179185

0 commit comments

Comments
 (0)