[PATCH] D145974: [libclang] Add index option to store preambles in memory

Igor Kushnir via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 13 12:10:42 PDT 2023


vedgy added a comment.

I have implemented the setter for the new option locally and tested it in KDevelop.

  void clang_CXIndex_setStorePreamblesInMemory(CXIndex CIdx,
                                               int storePreamblesInMemory) {
    if (CIdx)
      static_cast<CIndexer *>(CIdx)->setStorePreamblesInMemory(
          storePreamblesInMemory);
  }

Works as expected: new preambles are created in memory or the temporary directory depending on the option selected in the UI. Even if the temporary storage option ends up in memory, all remaining preambles are removed from the temporary directory on exit.

This simple setter approach was rejected in recent comments under D143418 <https://reviews.llvm.org/D143418> for valid reasons. But this quick test proves that changing the option on the fly is viable. Currently I don't think that the option change taking effect without restarting KDevelop justifies the effort of implementing the setter as `clang_parseTranslationUnitWithOptions()`. I expect this option's value to be changed very rarely. So I don't plan to change preamble storage API after this review.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145974



More information about the cfe-commits mailing list