Skip to content

Commit 597b4ae

Browse files
committed
Frontend: force order of evaluation
The previous statement happened to work out of sheer luck. `MainModule` is initialized by the call to `getMainModule()`. The expression could be evaluated in any order, and in the Visual Studio case, was evaluated with the index *first*. At this point `MainModule` was uninitialized (fortunately, it was set to NULL). As a result, the `getName` call would fail. Ensure that the `MainModule` is initialized first by using a local variable.
1 parent 7c186dd commit 597b4ae

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lib/Frontend/Frontend.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,9 @@ void CompilerInstance::performSemaUpTo(SourceFile::ASTStage_t LimitStage) {
517517
}
518518

519519
FrontendStatsTracer tracer(Context->Stats, "perform-sema");
520-
Context->LoadedModules[MainModule->getName()] = getMainModule();
520+
521+
ModuleDecl *mainModule = getMainModule();
522+
Context->LoadedModules[mainModule->getName()] = mainModule;
521523

522524
if (Invocation.getInputKind() == InputFileKind::SIL) {
523525
assert(!InputSourceCodeBufferIDs.empty());

0 commit comments

Comments
 (0)