Question about ASTReader::resolvePendingMacro, namely SkipDirectiveHistory

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Question about ASTReader::resolvePendingMacro, namely SkipDirectiveHistory

Tom Stellard via cfe-dev
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
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Question about ASTReader::resolvePendingMacro, namely SkipDirectiveHistory

Tom Stellard via cfe-dev
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" <[hidden email]>:

> 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
> [hidden email]
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev