Commit Graph

40 Commits

Author SHA1 Message Date
Sameer Rahmani 785ae7e7b1
Fix the incorrect include path of Triple.h 2023-02-08 15:30:48 +00:00
Kim Gräsman d888b82d4f [clang compat] Use new header for frontend diagnostics
In December 2018, the header clang/Frontend/FrontendDiagnostic.h moved
to clang/Basic/DiagnosticFrontend.h. The old header was left around for
compatibility.

Use the new one instead.

Sorry I'm late.
2023-01-07 21:26:41 +01:00
Kim Gräsman d7e4a20e8f Clean out IWYU pragma comments in IWYU itself
None of these pragmas are necessary at this point.
2023-01-07 21:26:41 +01:00
Et7f3 24985e2ecf
fix: Don't force pull MacOs libcxx's header
As a fix for issue #247 we added a block of hard-coded paths to the
include search path, which would find libc++ from the MacOS SDK.

While the MacOS SDK is usually present where IWYU is run, on developer
machines, there may be any number of other sysroots providing libc++
that users would prefer to use.

The Nix tool is one such player, where builds are isolated and all
dependencies are gathered in a single root for reproducibility.

Recent experiments with Clang on different Mac systems show that:

* if the MacOS SDK is present, IWYU picks it up automatically via the
  Clang driver
* if the MacOS SDK is not present, no include paths are conjured out of
  thin air
* Clang installed from Homebrew llvm package automatically finds the
  libc++ also provided as part of that package

It seems only IWYU forcefully adds magic paths, and it causes
problems for folks who want to do the right thing and build the sysroot
themselves. So remove these hard-coded paths.

If there is no installation of libc++ discoverable to Clang's probing,
or an alternative libc++ is desired, users can disable probing and
specify relevant paths directly on command-line:

  # for Homebrew version of llvm-14
  include-what-you-use -nostdinc++ \
      -isystem /opt/homebrew/opt/llvm\@14/include/c++/v1 \
      sourcefile.cc

  # for Apple Command Line Tools version of libc++
  include-what-you-use -nostdinc++ \
      -isystem /Library/Developer/CommandLineTools/usr/include/c++/v1 \
      sourcefile.cc

The mechanics of this technique is described in more detail for Clang:
https://libcxx.llvm.org//UsingLibcxx.html#using-a-custom-built-libc.

Co-authored-by: Kim Gräsman <kim.grasman@gmail.com>
2022-10-08 11:59:14 +02:00
Kim Gräsman eee6d6a199 Drop -save-temps command-line args
IWYU doesn't produce any outputs, so -save-temps does not have any useful
effect.

Before this patch, passing -save-temps did, however, generate multiple
compilation jobs which caused a fatal error:

  error: unable to handle compilation, expected exactly one compiler job

Filter the arguments out, similar to what Clang tools do by default.

Fixes issue #1060.
2022-09-01 20:03:59 +02:00
Andrea Bocci 53487d2097 Add explicit conversion from llvm::StringRef to std::string
llvm/llvm-project@777180a makes the llvm::StringRef conversion operator
to std::string explicit.
These changes add a call to the str() method to perform the conversion.

Signed-off-by: Andrea Bocci <andrea.bocci@cern.ch>
2020-03-03 21:44:35 +01:00
Kim Grasman b8edb821f2 Clang r370122: ArrayRef in CompilerInvocation::CreateFromArgs
Update to use new API.
2019-09-01 16:29:49 +02:00
Kim Grasman 8b6f243e42 Update for Clang r344337
For some reason, when Clang went from:

  using llvm::opt::ArgStringList;

to

  using ArgStringList = llvm::opt::ArgStringList;

my GCC no longer considers ArgStringList part of the clang::driver
namespace.

Use the qualified name llvm::opt::ArgStringList as was subsequently done
in clang-interpreter in r344400.

No functional change.
2018-10-13 15:41:45 +02:00
Kim Grasman 7b8980310f Remove dead synthesis of resource dir
HeaderSearchOpts.ResourceDir is never empty, so this code would never
execute.

Besides, it's too late to set the resource dir here; it's already been
used in Driver::BuildCompilation to build toolchain paths relative to
the compiler executable.
2018-09-17 20:58:06 +02:00
Kim Grasman da5c9b17fe Update to reflect changes in Clang
r291184 switched the CompilerInvocation argument to a shared_ptr.
2017-01-06 10:56:09 +01:00
EugeneZelenko eb7f5d1ef0 Fix Clang-tidy warnings
- readability-redundant-member-init warnings
- modernize nested templates; '> >'
- modernize-use-default warnings
2016-11-16 21:04:24 +01:00
Volodymyr Sapsai 9ab7286d56 On macOS search for libc++ headers in command-line tools and Xcode (fix issue #247).
PR https://github.com/include-what-you-use/include-what-you-use/pull/360
2016-09-18 21:08:27 -07:00
EugeneZelenko e05d81f32d Fix some Clang-tidy warnings
NULL/0 -> nullptr
C standard library include -> C++ counterparts
Occasional use of auto
Explicit strcmp return value check
Remove unused usings
Closing comments for anonymous namespaces
2016-06-07 21:49:33 +02:00
Kim Grasman 75754cec91 Clang in cl-mode now supports -fsyntax-only.
Remove special-casing with /Zs.
Adjust test not to pass invalid args (/C now requires /P)
2015-07-23 18:43:25 +02:00
Kim Gräsman 4d4f24d451 Add support for MSVC cl-compatible command-line switches.
Patch from Paul Redmond with test by me.
2014-12-14 21:36:35 +00:00
Kim Gräsman 0be0578119 Update to reflect changes in Clang.
As of Clang r218938, JobList uses a different iterator type,
and begin no longer needs double dereference.
2014-10-03 21:58:42 +00:00
Volodymyr Sapsai 6754618da7 Update to reflect changes in Clang.
JobList started using unique_ptr in r217168.
2014-09-05 05:08:19 +00:00
Volodymyr Sapsai 57a544b83c Update to reflect changes in LLVM.
MemoryBuffer API was updated to use llvm::ErrorOr in r212405.
2014-07-07 02:35:16 +00:00
Volodymyr Sapsai 0133e14917 Update to reflect changes in LLVM (issue #149).
"llvm/Support/system_error.h" was removed in LLVM r210803.  Replaced
llvm::error_code with std::error_code.
2014-06-13 16:36:34 +00:00
Volodymyr Sapsai fbe1e8b378 Update to reflect changes in LLVM.
Last uses of OwningPtr from llvm where removed in r209103.  Replaced 
llvm::OwningPtr with std::unique_ptr.
2014-05-20 13:26:21 +00:00
Volodymyr Sapsai c339cea626 Update to reflect changes in Clang.
DefaultImageName from the Driver constructor was eliminated in Clang r208926.
2014-05-18 15:54:14 +00:00
Volodymyr Sapsai e825dd5975 Update to reflect changes in Clang.
In Clang r190620 Compilation::PrintJob was moved into Job::Print.
2013-09-15 22:35:18 +00:00
Kim Gräsman 837e94beb4 Fix license header for iwyu_driver.cc. 2013-08-04 08:57:25 +00:00
Volodymyr Sapsai 269df45f4d Update to reflect changes in LLVM.
llvm/Support/PathV1.h was removed in LLVM r184960.
2013-06-30 17:31:14 +00:00
Volodymyr Sapsai 21d7aaad2e Update to reflect changes in Clang.
In Clang r172904 bitreader dependency was introduced (CMake build succeeds
without bitreader dependency).
In Clang r172945 argc, argv were removed from createDiagnostics.
2013-01-20 17:18:45 +00:00
Volodymyr Sapsai 09aff0f297 Update to reflect changes in Clang. Patch by Kim Gräsman.
In Clang r168703 was changed arguments list of clang::driver::Driver constructor.
2012-11-28 09:41:45 +00:00
Volodymyr Sapsai 5e6ee85bf7 Update to reflect changes in Clang. Now DiagnosticOptions are intrusively reference-counted (r166508). 2012-10-25 21:01:41 +00:00
csilvers+iwyu bfc26a7475 Compile cleanly under -Wno-switch-redundant-default.
tested:
http://sponge.corp.google.com/invocations?label=1d6f1b92054a4be09bab317ae6253d1c
http://sponge.corp.google.com/invocations?label=8f43351e76b5c4458ebb59a35f1cbc8b

R=chandlerc,matthewbg


Revision created by MOE tool push_codebase.
MOE_MIGRATION=4123
2012-01-24 18:37:19 +00:00
csilvers+iwyu 6ddbb290e9 s/getHostTriple/getDefaultTargetTriple/
R=csilvers,chandlerc


Revision created by MOE tool push_codebase.
MOE_MIGRATION=3604
2011-11-02 21:47:21 +00:00
csilvers+iwyu a9d7bb0a8a Fix to match a clang API update.
Revision created by MOE tool push_codebase.
MOE_MIGRATION=3404
2011-10-05 18:51:24 +00:00
csilvers+iwyu f7de7cb7f6 Monday morning, time for an integrate.
Changes of particular note:
* Resolved merge conflicts in:
third_party/llvm/libcxx/src/exception.cpp
third_party/llvm/llvm/tools/clang/lib/Driver/Tools.cpp
third_party/llvm/llvm/tools/clang/tools/driver/cc1_main.cpp
* Manual edits to
third_party/llvm/llvm/tools/clang/lib/Tooling/Tooling.cpp
due to diagnostic classes renaming
* Fixed up Cymbal, Grok and IWYU code for various class renamings

R=chandlerc,csilvers,chrsmith


Revision created by MOE tool push_codebase.
MOE_MIGRATION=3337
2011-09-26 19:46:13 +00:00
csilvers+iwyu 43fcb7fd19 Normalize the namespace qualifications of no_forward_declare symbols.
This fixes an issue I ran across where I couldn't inhibit the forward declaration
of a symbol defined in an anonymous namespace.

R=csilvers
DELTA=59  (53 added, 0 deleted, 6 changed)


Revision created by MOE tool push_codebase.
MOE_MIGRATION=3326
2011-09-26 19:45:57 +00:00
csilvers 409491b570 Diagnostic -> DiagnosticsEngine 2011-09-26 18:13:15 +00:00
csilvers+iwyu c11ac95479 Opensource iwyu is failing to compile because of missing using
statements for cast, isa, and dyn_cast.  I don't know what's
changed (maybe upstream took out a using statement somewhere
that we were depending on?), but it was our bad in the first
place, so I'm happy to fix it.

Because we try not to use using statements in .h files, I just
prefixed ::llvm:: there when appropriate.

R=wan
DELTA=13  (8 added, 0 deleted, 5 changed)


Revision created by MOE tool push_codebase.
MOE_MIGRATION=2674
2011-07-20 22:45:48 +00:00
csilvers+iwyu 3d55404056 Include-what-you-use fixes by running it on itself.
R=dsturtevant,csilvers
	DELTA=215  (135 added, 45 deleted, 35 changed)


Revision created by MOE tool push_codebase.
MOE_MIGRATION=1731
2011-05-04 18:29:59 +00:00
csilvers+iwyu ed381497a3 Add a test to protect against syntax errors in main(). Also
test some main()-invariant logic while I'm at it.

DELTA=19  (16 added, 0 deleted, 3 changed)


Revision created by MOE tool push_codebase.
MOE_MIGRATION=1409
2011-04-13 03:11:35 +00:00
csilvers+iwyu 37c67ac363 I was not correctly getting the location for member-exprs. I
thought I was saying the location is where the . (or ->) is,
which is what I want, but clang doesn't actually expose that.
So I have go through some hoops to try to figure it out.

We were actually seeing a problem with this when running:

blaze build --host_cpu=k8 --compile_only -k --crosstool_top=//third_party/llvm/crosstool --plugin=//devtools/maintenance/include_what_you_use:run_iwyu //gws/plugins/local/src:enhanced_listing_ad

It has 'msg_->MSG_foo' in it, where MSG_foo is a macro.  We
were attributing this use to the file defining MSG_foo, rather
than to us.  With this change, we properly attribute it to us.

R=dsturtevant
DELTA=150  (125 added, 6 deleted, 19 changed)


Revision created by MOE tool push_codebase.
MOE_MIGRATION=1347
2011-04-12 05:00:17 +00:00
csilvers 01f98c0fdc Fix the BuildCompilation call to match clang ToT. Fixes
http://code.google.com/p/include-what-you-use/issues/detail?id=24
2011-03-26 22:25:25 +00:00
csilvers+iwyu 83c3d667fa Put the driver routine in the iwyu namespace, at wan's
suggestion.

R=wan
DELTA=12  (7 added, 3 deleted, 2 changed)


Revision created by MOE tool push_codebase.
MOE_MIGRATION=1073
2011-03-26 22:15:12 +00:00
csilvers+iwyu 0d6022a68b Move the driver-startup code to iwyu_driver.cc. This
makes iwyu.cc cleaner.

For now, we use it only for iwyu_tests.cc, which needs
InitGlobal() to be called, which needs a CompilerInstance.

DELTA=516  (285 added, 210 deleted, 21 changed)


Revision created by MOE tool push_codebase.
MOE_MIGRATION=919
2011-03-18 07:00:23 +00:00