[cfe-dev] Question about ASTReader::resolvePendingMacro, namely SkipDirectiveHistory

via cfe-dev cfe-dev at lists.llvm.org
Thu Nov 28 22:49:19 PST 2019


Well I see, that for modules, ASTWriter calls shouldIgnoreMacro, and it allows to skip all built-ins and predefines.

But preamble seems to be an inevitable destination for predefines. So predefinitions go to .PCH.

Note in the end of clang::InitializePreprocessor there are lines to instruct PP to skip preamble bytes:

  // Instruct the preprocessor to skip the preamble.
  PP.setSkipMainFilePreamble(InitOpts.PrecompiledPreambleBytes.first,
                             InitOpts.PrecompiledPreambleBytes.second);

But if I got right this is different. Namely it's about implicit preambles. When we mark part of main file buffer as a preamble, we kindly ask PP to skip its part.

-Stepan

27.11.2019, 22:10, "via cfe-dev" <cfe-dev at lists.llvm.org>:
> Hi folks!
> I'm just checking a ASTReader::resolvePendingMacro, and looking at lines:
>
>   // Don't read the directive history for a module; we don't have anywhere
>   // to put it.
>   if (M.isModule())
>     return;
>
> So there is a question, first why it is called DirectiveHistory? Why just not a directive?
> Another thing is why we should skip it? I mean, we can store it in ASTReader::PP, and later if we're compiling another module we skip it, for it doesn't belong to current file right?
>
> Or from another side, can't we just define something in one module and take it into account in another (dependent) one?
>
> Thanks!
> -Stepan
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev



More information about the cfe-dev mailing list