Page MenuHomePhabricator

[analyzer] Add analyzer option to limit the number of imported TUs
Needs ReviewPublic

Authored by gamesh411 on Mar 25 2019, 1:42 PM.

Details

Reviewers
martong
xazax.hun
Summary

During CTU analysis of complex projects, the loaded AST-contents of
imported TUs can grow bigger than available system memory. This option
introduces a threshold on the number of TUs to be imported for a single
TU in order to prevent such cases.

Diff Detail

Event Timeline

gamesh411 created this revision.Mar 25 2019, 1:42 PM
Herald added a project: Restricted Project. · View Herald Transcript
gamesh411 retitled this revision from Add analyzer option to limit the number of imported TUs to [WIP] Add analyzer option to limit the number of imported TUs.Mar 25 2019, 1:56 PM

Updated option handling location to use AnalyzerOptions instead of CC1

gamesh411 retitled this revision from [WIP] Add analyzer option to limit the number of imported TUs to Add analyzer option to limit the number of imported TUs.Mar 28 2019, 12:33 AM
gamesh411 retitled this revision from Add analyzer option to limit the number of imported TUs to [analyzer] Add analyzer option to limit the number of imported TUs.Mar 28 2019, 12:41 AM

@xazax.hun Could you please take a look?

Mostly looks good, I have two slightly related nits.

include/clang/CrossTU/CrossTranslationUnit.h
129

I would prefer to keep the default argument for DisplayCTUProgress. You could do this either by swapping the arguments or adding a default argument to CTULoadThreshold as well. I think I might prefer the latter.

187

Does it make sense to call getCrossTUDefinition with different thresholds for the same CTUContext? I suspect it is not, so it might make more sense to set the threshold in the context's constructor.

gamesh411 updated this revision to Diff 199277.May 13 2019, 9:17 AM

Apply review suggestions by Xazax

gamesh411 marked an inline comment as done.May 13 2019, 9:22 AM

I could greatly simplify the API of getCrossTUDefinition by injecting the threshold value in the constructor. A minor drawback with this approach is that testing code is a bit more complicated, as I had to patch the CompilerInstance to override the AnalyzerOption value for CTUImportThreshold. Thanks for the suggestion!

gamesh411 marked an inline comment as done.May 13 2019, 9:23 AM
gamesh411 updated this revision to Diff 199278.May 13 2019, 9:28 AM

Revert unnecessary clang-formating of AnalysisConsumer.cpp