Repository: dotnet/runtime
File: src/coreclr/interpreter/eeinterp.cpp (C++)

Code before:
        doInterpret = true;
#else
        // NOTE: We do this check even if doInterpret==true in order to populate g_interpModule
        const char *methodName = compHnd->getMethodNameFromMetadata(methodInfo->ftn, nullptr, nullptr, nullptr, 0);
        if (InterpConfig.Interpreter().contains(compHnd, methodInfo->ftn, compHnd->getMethodClass(methodInfo->ftn), &methodInfo->args))
        {
            doInterpret = true;
            g_interpModule = methodInfo->scope;
        }
#endif
    }

    if (!doInterpret)
    {
        return CORJIT_SKIPPED;
    }

    try
    {
        InterpreterRetryData retryData;

        InterpMethod *pMethod = NULL;
        while (true)
        {
            retryData.StartCompilationAttempt();
            InterpCompiler compiler(compHnd, methodInfo, &retryData);
            InterpMethod *pMethod = compiler.CompileMethod();
            if (pMethod == NULL)
            {
                assert(retryData.NeedsRetry());
                continue;
            }

            // Once we reach here we will not attempt to retry again.
            assert(!retryData.NeedsRetry());

            int32_t IRCodeSize = 0;
            int32_t *pIRCode = compiler.GetCode(&IRCodeSize);

            uint32_t sizeOfCode = sizeof(InterpMethod*) + IRCodeSize * sizeof(int32_t);
            uint8_t unwindInfo[8] = {0, 0, 0, 0, 0, 0, 0, 0};

            AllocMemArgs args {};
            args.hotCodeSize = sizeOfCode;
            args.coldCodeSize = 0;
            args.roDataSize = 0;
            args.xcptnsCount = 0;
            args.flag = CORJIT_ALLOCMEM_DEFAULT_CODE_ALIGN;
            compHnd->allocMem(&args);

            // We store first the InterpMethod pointer as the code header, followed by the actual code

Review comment (suggestion):
Variable shadowing issue: `pMethod` is declared on line 111 and then shadowed by this local declaration on line 116. The inner declaration shadows the outer one, making the outer variable unused and potentially causing confusion. Remove the `InterpMethod *` type specifier from this line.
```suggestion
            pMethod = compiler.CompileMethod();
```

Code after:
        doInterpret = true;
#else
        // NOTE: We do this check even if doInterpret==true in order to populate g_interpModule
        const char *methodName = compHnd->getMethodNameFromMetadata(methodInfo->ftn, nullptr, nullptr, nullptr, 0);
        if (InterpConfig.Interpreter().contains(compHnd, methodInfo->ftn, compHnd->getMethodClass(methodInfo->ftn), &methodInfo->args))
        {
            doInterpret = true;
            g_interpModule = methodInfo->scope;
        }
#endif
    }

    if (!doInterpret)
    {
        return CORJIT_SKIPPED;
    }

    try
    {
        InterpreterRetryData retryData;

        while (true)
        {
            retryData.StartCompilationAttempt();
            InterpCompiler compiler(compHnd, methodInfo, &retryData);
            InterpMethod *pMethod = compiler.CompileMethod();
            if (pMethod == NULL)
            {
                assert(retryData.NeedsRetry());
                continue;
            }

            // Once we reach here we will not attempt to retry again.
            assert(!retryData.NeedsRetry());

            int32_t IRCodeSize = 0;
            int32_t *pIRCode = compiler.GetCode(&IRCodeSize);

            uint32_t sizeOfCode = sizeof(InterpMethod*) + IRCodeSize * sizeof(int32_t);
            uint8_t unwindInfo[8] = {0, 0, 0, 0, 0, 0, 0, 0};

            AllocMemArgs args {};
            args.hotCodeSize = sizeOfCode;
            args.coldCodeSize = 0;
            args.roDataSize = 0;
            args.xcptnsCount = 0;
            args.flag = CORJIT_ALLOCMEM_DEFAULT_CODE_ALIGN;
            compHnd->allocMem(&args);

            // We store first the InterpMethod pointer as the code header, followed by the actual code
            *(InterpMethod**)args.hotCodeBlockRW = pMethod;