Skip to content

Commit

Permalink
Revert hack for passing MainFileIsHeader
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-jabbour-sonarsource committed Dec 2, 2024
1 parent 8995923 commit aec5103
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ public void TryGet_HeaderFileOptions_ReturnsValidConfig()
// Assert
request.Should().NotBeNull();
Assert.AreEqual("\"C:\\path\\cl.exe\" /Yu\"pch.h\" /FI\"pch.h\" /EHsc /RTCu \"c:\\dummy\\file.h\"", request.CDCommand);
Assert.AreEqual("non_existent_file", request.CDFile);
Assert.AreEqual("c:\\dummy\\file.h", request.CDFile);

// Arrange
projectItemConfig.FileConfigProperties["CompileAs"] = "CompileAsC";
Expand All @@ -185,7 +185,7 @@ public void TryGet_HeaderFileOptions_ReturnsValidConfig()

// Assert
Assert.AreEqual("\"C:\\path\\cl.exe\" /FI\"FHeader.h\" /Yu\"pch.h\" /EHsc /RTCu /TC \"c:\\dummy\\file.h\"", request.CDCommand);
Assert.AreEqual("non_existent_file", request.CDFile);
Assert.AreEqual("c:\\dummy\\file.h", request.CDFile);

// Arrange
projectItemConfig.FileConfigProperties["CompileAs"] = "CompileAsCpp";
Expand All @@ -195,7 +195,7 @@ public void TryGet_HeaderFileOptions_ReturnsValidConfig()

// Assert
Assert.AreEqual("\"C:\\path\\cl.exe\" /FI\"FHeader.h\" /Yu\"pch.h\" /EHsc /RTCu /TP \"c:\\dummy\\file.h\"", request.CDCommand);
Assert.AreEqual("non_existent_file", request.CDFile);
Assert.AreEqual("c:\\dummy\\file.h", request.CDFile);
}

[TestMethod]
Expand Down
7 changes: 2 additions & 5 deletions src/Integration.Vsix/CFamily/VcxProject/FileConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ public static FileConfig TryGet(ILogger logger, ProjectItem dteProjectItem, stri
return null;
}

var isHeader = vcFile.ItemType == "ClInclude";
CmdBuilder cmdBuilder = new CmdBuilder(isHeader);
CmdBuilder cmdBuilder = new CmdBuilder(vcFile.ItemType == "ClInclude");

var compilerPath = vcConfig.GetEvaluatedPropertyValue("ClCompilerPath");
if (string.IsNullOrEmpty(compilerPath))
Expand Down Expand Up @@ -76,9 +75,7 @@ public static FileConfig TryGet(ILogger logger, ProjectItem dteProjectItem, stri
{
CDDirectory = Path.GetDirectoryName(vcProject.ProjectFile),
CDCommand = cmdBuilder.GetFullCmd(),
// A hack to communicate with the CFamily analyzer that this is a header file.
// A long-term solution should be investigated in CPP-5898.
CDFile = isHeader ? "non_existent_file" : absoluteFilePath,
CDFile = absoluteFilePath,
EnvInclude = envINCLUDE,
};
}
Expand Down

0 comments on commit aec5103

Please sign in to comment.