Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[cling] Support bare # in input line: #14109

Merged
merged 2 commits into from
Jan 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions interpreter/cling/lib/MetaProcessor/InputValidator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,17 +82,19 @@ namespace cling {
case tok::hash:
Lex.SkipWhitespace();
Lex.LexAnyString(Tok);
const llvm::StringRef PPtk = Tok.getIdent();
if (PPtk.startswith("if")) {
m_ParenStack.push_back(tok::hash);
} else if (PPtk.startswith("endif") &&
(PPtk.size() == 5 || PPtk[5]=='/' || isspace(PPtk[5]))) {
if (Tok.isNot(tok::eof)) {
const llvm::StringRef PPtk = Tok.getIdent();
if (PPtk.startswith("if")) {
m_ParenStack.push_back(tok::hash);
} else if (PPtk.startswith("endif") &&
(PPtk.size() == 5 || PPtk[5] == '/' || isspace(PPtk[5]))) {
if (m_ParenStack.empty() || m_ParenStack.back() != tok::hash)
Res = kMismatch;
else
m_ParenStack.pop_back();
}
break;
}
break;
}
} while (Tok.isNot(tok::eof) && Res != kMismatch);

Expand Down
7 changes: 7 additions & 0 deletions interpreter/cling/lib/MetaProcessor/MetaLexer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,13 @@ namespace cling {
void MetaLexer::LexAnyString(Token& Tok) {
Tok.startToken(curPos);
// consume until we reach one of the "AnyString" delimiters or EOF.
if (*curPos == '\0') {
Tok.setBufStart(curPos);
Tok.setKind(tok::eof);
Tok.setLength(0);
return;
}

while(*curPos != ' ' && *curPos != '\t' && *curPos != '\0') {
curPos++;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
// LICENSE.TXT for details.
//------------------------------------------------------------------------------

// clang-format off
// RUN: cat %s | %cling | FileCheck %s
"simple"
//CHECK: (const char[7]) "simple"
Expand All @@ -17,4 +18,6 @@
//CHECK: (const char[24]) "http://foo/bar/whatever"
("http://foo.bar/whatever")
//CHECK: (const char[24]) "http://foo.bar/whatever"
#
// CHECK-EMPTY:
.q
Loading