]> granicus.if.org Git - clang/commitdiff
[Modules] Do not diagnose missing import in recovery mode if there isn't a decl to...
authorBruno Cardoso Lopes <bruno.cardoso@gmail.com>
Wed, 16 May 2018 17:00:24 +0000 (17:00 +0000)
committerBruno Cardoso Lopes <bruno.cardoso@gmail.com>
Wed, 16 May 2018 17:00:24 +0000 (17:00 +0000)
Clang often tries to create implicit module import for error recovery,
which does a great job helping out with diagnostics. However, sometimes
clang does not have enough information given that it's using an invalid
context to move on. Be more strict in those cases to avoid crashes.

We hit crash on invalids because of this but unfortunately there are no
testcases and I couldn't manage to create one. The crashtrace however
indicates pretty clear why it's happening.

rdar://problem/39313933

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@332491 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaType.cpp

index b51d49461feb47046fca4eecfb0a92efe01ddc48..7e8f9b19e3d570af57509f1f8de11c39fca6548d 100644 (file)
@@ -7613,7 +7613,7 @@ bool Sema::RequireCompleteTypeImpl(SourceLocation Loc, QualType T,
       // If the user is going to see an error here, recover by making the
       // definition visible.
       bool TreatAsComplete = Diagnoser && !isSFINAEContext();
-      if (Diagnoser)
+      if (Diagnoser && SuggestedDef)
         diagnoseMissingImport(Loc, SuggestedDef, MissingImportKind::Definition,
                               /*Recover*/TreatAsComplete);
       return !TreatAsComplete;