[PATCH] D126266: Mark the file entry invalid, until reread. Invalidate SLocEntry cache, readd it on reread. Do not use translateFile, because it pulls in parts of the pch.

Vassil Vassilev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sat Jun 25 09:17:28 PDT 2022


v.g.vassilev added a comment.

After landing https://reviews.llvm.org/D126682 we might be able to write a test in clang-repl such as:

  cpp
  clang-repl> #include <iostream>
  clang-repl> #include <fstream>
  clang-repl>using namespace std;
  clang-repl> int write_str (const char* str) {
    ofstream myfile;
    myfile.open ("a.h");
    myfile << str<<"\n";
    myfile.close();
    return 0;
  }
  clang-repl> auto r1 = write_str("int i = 42");
  clang-repl> extern "C" int printf(const char*,...);
  clang-repl> #include "a.h"
  clang-repl> auto r2 = printf("i=%d\n", i);
  clang-repl>%undo
  clang-repl>%undo 
  clang-repl> auto r3 = write_str("int i = 0");
  clang-repl> #include "a.h"
  clang-repl> auto r2 = printf("i=%d\n", i);
  // Here we should print `i=0`.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D126266/new/

https://reviews.llvm.org/D126266



More information about the cfe-commits mailing list