Skip to content

Tests using /analyze:only should also use /analyze:autolog- #1416

@StephanTLavavej

Description

@StephanTLavavej

Several of our test configurations compile with /analyze:only. This emits a .nativecodeanalysis.xml file that we're never ever interested in. There's a (new?) compiler option to suppress this, /analyze:autolog-, which can be used with /analyze:only. Example:

C:\Temp>type meow.cpp && echo --- && dir /b meow.* && echo ---
#include <iostream>
using namespace std;

int f(int x, int y) {
    if (!x & y) {
        return 1;
    }
    return 0;
}

int main() {
    cout << "Hello, world!" << endl;
}
---
meow.cpp
---

C:\Temp>cl /EHsc /nologo /W4 /analyze meow.cpp && echo --- && dir /b meow.* && echo --- && del meow.exe meow.nativecodeanalysis.xml meow.obj
meow.cpp
C:\Temp\meow.cpp(5) : warning C6290: Bitwise operation on logical result:  ! has higher precedence than &.  Use && or (!(x & y)) instead.
---
meow.cpp
meow.exe
meow.nativecodeanalysis.xml
meow.obj
---

C:\Temp>cl /EHsc /nologo /W4 /analyze:autolog- meow.cpp && echo --- && dir /b meow.* && echo --- && del meow.exe meow.nativecodeanalysis.xml meow.obj
meow.cpp
C:\Temp\meow.cpp(5) : warning C6290: Bitwise operation on logical result:  ! has higher precedence than &.  Use && or (!(x & y)) instead.
---
meow.cpp
meow.exe
meow.obj
---

C:\Temp>cl /EHsc /nologo /W4 /analyze:only meow.cpp && echo --- && dir /b meow.* && echo --- && del meow.exe meow.nativecodeanalysis.xml meow.obj
meow.cpp
C:\Temp\meow.cpp(5) : warning C6290: Bitwise operation on logical result:  ! has higher precedence than &.  Use && or (!(x & y)) instead.
---
meow.cpp
meow.nativecodeanalysis.xml
---

C:\Temp>cl /EHsc /nologo /W4 /analyze:only /analyze:autolog- meow.cpp && echo --- && dir /b meow.* && echo ---
meow.cpp
C:\Temp\meow.cpp(5) : warning C6290: Bitwise operation on logical result:  ! has higher precedence than &.  Use && or (!(x & y)) instead.
---
meow.cpp
---

In #1394, I've pushed a commit to change plain /analyze to /analyze:autolog-. We should follow this up with another PR to change /analyze:only to /analyze:only /analyze:autolog-.

Aside: /analyze:only skips codegen, so we've generally paired it with a non-/analyze configuration, e.g.

PM_CL="/EHsc /MT /D_ITERATOR_DEBUG_LEVEL=0 /std:c++latest /permissive- /w14640 /Zc:threadSafeInit-"
PM_CL="/EHsc /MT /D_ITERATOR_DEBUG_LEVEL=0 /std:c++latest /permissive- /analyze:only /w14640 /Zc:threadSafeInit-"

Metadata

Metadata

Assignees

No one assigned

    Labels

    fixedSomething works now, yay!testRelated to test code

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions