This is an archive of the discontinued LLVM Phabricator instance.

[clang][Tooling] Prefer -x over -std when interpolating
ClosedPublic

Authored by kadircet on Dec 19 2019, 1:36 PM.

Details

Summary

Currently interpolation logic prefers -std over -x. But the latter is a
more strong signal, so this patch inverts the order and only makes use of -std
if -x didn't exist.

Fixes https://github.com/clangd/clangd/issues/185

Thanks @sammccall for tracking this down!

Diff Detail

Event Timeline

kadircet created this revision.Dec 19 2019, 1:36 PM

Unit tests: pass. 61035 tests passed, 0 failed and 728 were skipped.

clang-tidy: pass.

clang-format: pass.

Build artifacts: diff.json, clang-tidy.txt, clang-format.patch, CMakeCache.txt, console-log.txt, test-results.xml

kbobyrev accepted this revision.Dec 20 2019, 2:01 AM
kbobyrev added a subscriber: kbobyrev.

LGTM

This revision is now accepted and ready to land.Dec 20 2019, 2:01 AM
This revision was automatically updated to reflect the committed changes.

Thanks for taking care of this!

clang/lib/Tooling/InterpolatingCompilationDatabase.cpp
194

Note that type is initialized from guessType, not only -x, so this comment isn't true in general, just for *.h.

Example: if CDB contains clang -std=c++14 foo.cc, then we'll treat foo.mm as obj-c++ rather than c++. (The right thing in that case and probably in general)