HomePhabricator

[clang-tidy] Skip reporting of not applicable fixes.

Authored by etienneb on Mar 22 2016, 10:51 AM.

Description

[clang-tidy] Skip reporting of not applicable fixes.

Summary:
Invalid source location are causing clang-tidy to crash when manipulating an invalid file.

Macro definitions on the command line have locations in a virtual buffer and therefore
don't have a corresponding valid FilePath.

A recent patch added path conversion to absolute path. As the FilePath may now be empty,
the result of makeAbsolutePath may incorrectly be the folder WorkingDir. The crash occurs
in getLocation which is not able to find the appropriate FileEntry (null pointer).

SmallString<128> FixAbsoluteFilePath = Fix.getFilePath();
Files.makeAbsolutePath(FixAbsoluteFilePath);
FixLoc = getLocation(FixAbsoluteFilePath, Fix.getOffset());

With relative path, the code was not crashing because getLocation was skipping empty path.

Example of code:

int main() { return X; }

With the given command-line:

clang-tidy test.cc --checks=misc-macro-*  --  -DX=0+0

Reviewers: alexfh, aaron.ballman

Subscribers: aaron.ballman, cfe-commits

Differential Revision: http://reviews.llvm.org/D18262

llvm-svn: 264073

Details

Committed
etiennebMar 22 2016, 10:51 AM
Differential Revision
D18262: [clang-tidy] Skip reporting of not applicable fixes.
Parents
rG6b535630a122: Add a hasOperandBundlesOtherThan helper, and use it; NFC
Branches
Unknown
Tags
Unknown