================
@@ -578,6 +578,25 @@ Module *Preprocessor::getCurrentModuleImplementation() {
   return getHeaderSearchInfo().lookupModule(getLangOpts().ModuleName);
 }
 
+bool Preprocessor::LexTokensInString(SmallVectorImpl<Token> &Tokens,
+                                     StringRef Code, SourceLocation Loc) {
+  std::unique_ptr<Lexer> L = Lexer::CreateScratchLexer(Code, Loc, Loc, *this);
+  L->LexingInjectedString = true;
+  EnterSourceFileWithLexer(std::move(L), /*Dir=*/nullptr);
+  for (;;) {
+    Token Tok;
+    Lex(Tok);
+    Tokens.push_back(Tok);
+    if (Tok.is(tok::eof)) {
+      // Ignore the return value of HandleEndOfFile(): it tells us whether we
+      // should call Lex() again to get the next token, which we don't want to
+      // to do here anyway.
+      HandleEndOfFile(Tok, /*isEndOfMacro=*/false);
----------------
zwuis wrote:

EOF checks this function treat the `false` as a real EOF for `#pragma clang 
assume_nonnull` and `#pragma clang arc_cf_code_audited`.

<details>
<summary>Reproducer</summary>

```cpp
#pragma clang assume_nonnull begin
//            ^^^^^^^^^^^^^^ or arc_cf_code_audited
void f() {
  static constexpr Array<int, 3> a;
  template for (auto x : a)
    ;
}
#pragma clang assume_nonnull end
```

</details>

https://github.com/llvm/llvm-project/pull/208877
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to