r356432 - Don't apply the include depth limit until we actually decide to enter

Richard Smith via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 18 18:51:17 PDT 2019


Author: rsmith
Date: Mon Mar 18 18:51:17 2019
New Revision: 356432

URL: http://llvm.org/viewvc/llvm-project?rev=356432&view=rev
Log:
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.

Modified:
    cfe/trunk/lib/Lex/PPDirectives.cpp

Modified: cfe/trunk/lib/Lex/PPDirectives.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPDirectives.cpp?rev=356432&r1=356431&r2=356432&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/PPDirectives.cpp (original)
+++ cfe/trunk/lib/Lex/PPDirectives.cpp Mon Mar 18 18:51:17 2019
@@ -1724,13 +1724,6 @@ void Preprocessor::HandleIncludeDirectiv
   // 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::HandleIncludeDirectiv
     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




More information about the cfe-commits mailing list