Remove const reference to errorReporter.
Fixes use-after-free ASAN failure.
PiperOrigin-RevId: 204177796
diff --git a/lib/Parser/Lexer.h b/lib/Parser/Lexer.h
index 730bbc9..f9cdfb6 100644
--- a/lib/Parser/Lexer.h
+++ b/lib/Parser/Lexer.h
@@ -30,7 +30,7 @@
/// This class breaks up the current file into a token stream.
class Lexer {
llvm::SourceMgr &sourceMgr;
- const SMDiagnosticHandlerTy &errorReporter;
+ const SMDiagnosticHandlerTy errorReporter;
StringRef curBuffer;
const char *curPtr;
@@ -38,16 +38,16 @@
Lexer(const Lexer&) = delete;
void operator=(const Lexer&) = delete;
public:
- explicit Lexer(llvm::SourceMgr &sourceMgr,
- const SMDiagnosticHandlerTy &errorReporter);
+ explicit Lexer(llvm::SourceMgr &sourceMgr,
+ SMDiagnosticHandlerTy errorReporter);
- llvm::SourceMgr &getSourceMgr() { return sourceMgr; }
+ llvm::SourceMgr &getSourceMgr() { return sourceMgr; }
- Token lexToken();
+ Token lexToken();
- /// Change the position of the lexer cursor. The next token we lex will start
- /// at the designated point in the input.
- void resetPointer(const char *newPointer) { curPtr = newPointer; }
+ /// Change the position of the lexer cursor. The next token we lex will start
+ /// at the designated point in the input.
+ void resetPointer(const char *newPointer) { curPtr = newPointer; }
private:
// Helpers.
Token formToken(Token::Kind kind, const char *tokStart) {