Skip to content

Commit

Permalink
[XLA:GPU][IndexAnalysis] Fix MSAN failure: 1st token was accessed bef…
Browse files Browse the repository at this point in the history
…ore initialization.

PiperOrigin-RevId: 678577534
  • Loading branch information
pifon2a authored and Google-ML-Automation committed Sep 25, 2024
1 parent 4c3c279 commit 0f1f3c6
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions xla/service/gpu/model/indexing_map_serialization.cc
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,17 @@ class Parser {
public:
explicit Parser(llvm::StringRef input) : input_(input), it_(input.begin()) {
// Set the parser to the first token.
Advance();
current_token_ = GetNextTokenImpl();
}

const Token& GetCurrentToken() const { return current_token_; };
void Advance() { current_token_ = GetNextTokenImpl(); }
void Advance() {
if (current_token_.kind == Token::Kind::kError ||
current_token_.kind == Token::Kind::kEOF) {
return;
}
current_token_ = GetNextTokenImpl();
}
Token GetNextToken() {
Advance();
return current_token_;
Expand Down Expand Up @@ -253,10 +259,6 @@ bool Parser::ConsumeToken(Token::Kind kind) {
}

Token Parser::GetNextTokenImpl() {
if (current_token_.kind == Token::Kind::kError ||
current_token_.kind == Token::Kind::kEOF) {
return current_token_;
}
ConsumeWhitespace();
if (it_ == input_.end()) {
return Token{"", Token::Kind::kEOF};
Expand Down

0 comments on commit 0f1f3c6

Please sign in to comment.