diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2019-03-19 01:51:17 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2019-03-19 01:51:17 +0000 |
commit | 5a8ea4ca9470358800836a932c2fccb8f3b5710c (patch) | |
tree | 5ebf5f2d03fe8bc5d5c86250c27a85f82ff45768 /clang/lib | |
parent | 0200d62ec7a54b79313bc2c4ccbe51c2a8c5e940 (diff) | |
download | bcm5719-llvm-5a8ea4ca9470358800836a932c2fccb8f3b5710c.tar.gz bcm5719-llvm-5a8ea4ca9470358800836a932c2fccb8f3b5710c.zip |
Don't apply the include depth limit until we actually decide to enter
the file.
NFC unless a skipped #include is found at the final permitted #include
level.
llvm-svn: 356432
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/Lex/PPDirectives.cpp | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/clang/lib/Lex/PPDirectives.cpp b/clang/lib/Lex/PPDirectives.cpp index 39501745292..62796293b4d 100644 --- a/clang/lib/Lex/PPDirectives.cpp +++ b/clang/lib/Lex/PPDirectives.cpp @@ -1724,13 +1724,6 @@ void Preprocessor::HandleIncludeDirective(SourceLocation HashLoc, // C99 6.10.2p4. CheckEndOfDirective(IncludeTok.getIdentifierInfo()->getNameStart(), true); - // Check that we don't have infinite #include recursion. - if (IncludeMacroStack.size() == MaxAllowedIncludeStackDepth-1) { - Diag(FilenameTok, diag::err_pp_include_too_deep); - HasReachedMaxIncludeDepth = true; - return; - } - // Complain about attempts to #include files in an audit pragma. if (PragmaARCCFCodeAuditedLoc.isValid()) { Diag(HashLoc, diag::err_pp_include_in_arc_cf_code_audited); @@ -2071,6 +2064,13 @@ void Preprocessor::HandleIncludeDirective(SourceLocation HashLoc, return; } + // Check that we don't have infinite #include recursion. + if (IncludeMacroStack.size() == MaxAllowedIncludeStackDepth-1) { + Diag(FilenameTok, diag::err_pp_include_too_deep); + HasReachedMaxIncludeDepth = true; + return; + } + // Look up the file, create a File ID for it. SourceLocation IncludePos = End; // If the filename string was the result of macro expansions, set the include |