Commit Graph

2034 Commits

Author SHA1 Message Date
Chandler Carruth 74e2c35fbc Inline this method now that its completely trivial, and prepare for
hoisting parts of the text diagnostic.

llvm-svn: 140477
2011-09-25 23:01:05 +00:00
Chandler Carruth 84f361950f Shuffle some names around. 'CaretDiagnostic' is inaccurate as this needs
to handle non-caret diagnostics as well in order to be fully useful in
libclang etc. Also sketch out some more of my plans on this refactoring.

llvm-svn: 140476
2011-09-25 22:54:56 +00:00
Chandler Carruth 3236f0d25c Actually remove the members of CaretDiagnostic no longer in use for
tracking the start and stop of macro expansion suppression. Also remove
the Columns variable which was just a convenience variable based on
DiagOpts. Instead we materialize it in the one piece of code that cared.

llvm-svn: 140475
2011-09-25 22:31:58 +00:00
Chandler Carruth cb8f82a8e5 Sink the logic for suppressing some macro expansion notes from the
TextDiagnosticPrinter into the CaretDiagnostic class. Several
interesting results from this:

- This removes a significant per-diagnostic bit of state from the
  CaretDiagnostic class, which should eventually allow us to re-use the
  object.
- It removes a redundant recursive walk of the macro expansion stack
  just to compute the depth. We don't need the depth until we're
  unwinding anyways, so we can just mark when we reach it.
- It also paves the way for several simplifications we can do to how we
  implement the suppression.

llvm-svn: 140474
2011-09-25 22:27:52 +00:00
Chandler Carruth 9d229f3eb1 Split the recursive macro expansion walk out from the routine which
emits a source snippet and caret line.

llvm-svn: 140467
2011-09-25 06:59:38 +00:00
Douglas Gregor 52da28be50 Don't translate CRLF files into LF files. Fixes PR6870, from Aaron Ballman!
llvm-svn: 140435
2011-09-23 23:43:36 +00:00
David Blaikie 7900020616 More missing header inclusions from llvm_unreachable migration.
llvm-svn: 140369
2011-09-23 05:57:42 +00:00
David Blaikie 83d382b1ca Switch assert(0/false) llvm_unreachable.
llvm-svn: 140367
2011-09-23 05:06:16 +00:00
Benjamin Kramer 559865c89d Reenable -cxx-isystem for Objective C++, until I come up with a better solution
llvm-svn: 140365
2011-09-23 02:25:14 +00:00
Benjamin Kramer 8404eb0bad Add support for CPATH and friends.
This moves the existing code for CPATH into the driver and adds the environment lookup and path splitting there.
The paths are then passed down to cc1 with -I options (CPATH), added after the normal user-specified include dirs.
Language specific paths are passed via -LANG-isystem and the actual filtering is performed in the frontend.

I tried to match GCC's behavior as close as possible

Fixes PR8971.

llvm-svn: 140341
2011-09-22 21:41:16 +00:00
Tobias Grosser 0a3a22fe66 In the OpenCL mode, the AltiVec mode must be off and checks must be strict
OpenCL is different from AltiVec in the way it supports vector literals.  OpenCL
is strict with regards to semantic checks.  For example, implicit conversions
and explicit casts between vectors of different types are disallowed.

Fixes PR10975. Submitted by: Anton Lokhmotov <Anton.lokhmotov@gmail.com>

llvm-svn: 140270
2011-09-21 18:28:29 +00:00
Eric Christopher 5507159245 Remove __WCHAR_UNSIGNED__ and anything that used it.
llvm-svn: 140155
2011-09-20 18:05:01 +00:00
Argyrios Kyrtzidis 5733271925 In libclang, when visiting preprocessed entities in a source range, use
PreprocessingRecord's getPreprocessedEntitiesInRange.

Also remove all the stuff that were added in ASTUnit that are unnecessary now
that we do a binary search for preprocessed entities and deserialize only
what is necessary.

llvm-svn: 140063
2011-09-19 20:40:48 +00:00
Argyrios Kyrtzidis 7f44836998 Introduce local_begin()/local_end() methods in PreprocessingRecord which
return iterators for local, non-loaded, preprocessed entities.

llvm-svn: 140062
2011-09-19 20:40:42 +00:00
Argyrios Kyrtzidis 7c06d8666b [libclang] When getting a source location from a file:line:col triplet
check whether the requested location points inside the precompiled preamble,
in which case the returned source location will be a "loaded" one.

llvm-svn: 140060
2011-09-19 20:40:35 +00:00
Argyrios Kyrtzidis e6e67deeed Rename SourceLocation::getFileLocWithOffset -> getLocWithOffset.
It already works (and is useful with) macro locs as well.

llvm-svn: 140057
2011-09-19 20:40:19 +00:00
Francois Pichet 26e809692a Do not use builtin includes if -fms-compatibility is specified. Some MSVC header files have the same name as clang's builtins, this creates clash.
llvm-svn: 140009
2011-09-19 05:15:54 +00:00
Francois Pichet 0706d203cf Rename LangOptions::Microsoft to LangOptions::MicrosoftExt to make it clear that this flag must be used only for Microsoft extensions and not emulation; to avoid confusion with the new LangOptions::MicrosoftMode flag.
Many of the code now under LangOptions::MicrosoftExt will eventually be moved under the LangOptions::MicrosoftMode flag.

llvm-svn: 139987
2011-09-17 17:15:52 +00:00
Francois Pichet 1b4f1637fb As per discussion with Doug Gregor on the IRC channel, introduce a new compiler switch: -fms-compatility.
Microsoft specific tweaking will now fall into 2 categories:

    - fms-extension: Microsoft specific extensions that should never change the meaning of an otherwise well formed code. Currently map to LangOptions::Microsoft. (To be clearer, I am planning to change the name to LangOptions::MicrosoftExt).

    - fms-compatibility: Really a MSVC emulation mode. Map to LangOptions::MicrosoftMode. Can change the meaning of an otherwise standard conformant program.

llvm-svn: 139978
2011-09-17 04:32:15 +00:00
Douglas Gregor 97eec24b0b Add an experimental flag -fauto-module-import that automatically turns
#include or #import direcctives of framework headers into module
imports of the corresponding framework module.

llvm-svn: 139860
2011-09-15 22:00:41 +00:00
Douglas Gregor 44bf68d819 Comment what's going on when we compile a module
llvm-svn: 139837
2011-09-15 20:53:28 +00:00
Douglas Gregor dff0e892db Detect cyclic module dependencies in a manner that is rather more
graceful than running out of stack space.

llvm-svn: 139833
2011-09-15 20:40:10 +00:00
Douglas Gregor 900d4bf80a Eliminate the list of modules from the preprocessor options. This was
used back when we had an -import-module command-line option, but it's
no longer used (or useful).

llvm-svn: 139829
2011-09-15 19:48:59 +00:00
Douglas Gregor 8a880e3ff6 Eliminate the unused -create-module cc1-level option
llvm-svn: 139827
2011-09-15 19:45:56 +00:00
Douglas Gregor 6137d32c1b When we load the first module, make sure that we wire up the ASTConsumer to the newly-created ASTReader. This makes sure that CodeGen sees the declarations it is interested in
llvm-svn: 139824
2011-09-15 18:47:32 +00:00
Argyrios Kyrtzidis 03c40c5182 [PCH] Overhaul how preprocessed entities are [de]serialized.
-Use an array of offsets for all preprocessed entities
-Get rid of the separate array of offsets for just macro definitions;
 for references to macro definitions use an index inside the preprocessed
 entities array.
-Deserialize each preprocessed entity lazily, at first request; not in bulk.

Paves the way for binary searching of preprocessed entities that will offer
efficiency and will simplify things on the libclang side a lot.

llvm-svn: 139809
2011-09-15 18:02:56 +00:00
Douglas Gregor 21931efc4d Make -E work with module imports
llvm-svn: 139750
2011-09-14 23:13:09 +00:00
Douglas Gregor a739d9a023 Encode the module hash in base-36, to reduce the length of the strings a bit
llvm-svn: 139696
2011-09-14 15:55:12 +00:00
Douglas Gregor 3728ea75d9 Assert that the module hash produced after stripping away non-modular options is the same as the module hash before stripping those options.
llvm-svn: 139663
2011-09-13 23:20:27 +00:00
Douglas Gregor 1735f4e752 For modules, use a hash of the compiler version, language options, and
target triple to separate modules built under different
conditions. The hash is used to create a subdirectory in the module
cache path where other invocations of the compiler (with the same
version, language options, etc.) can find the precompiled modules.

llvm-svn: 139662
2011-09-13 23:15:45 +00:00
Douglas Gregor f1312a828a When building a module on-demand, clear out the "non-modular" language
and preprocessor options (such as macro definitions) first.

llvm-svn: 139638
2011-09-13 20:44:41 +00:00
Douglas Gregor 79a91418bd Switch LangOptions over to a .def file that describes header of the
language options. Use that .def file to declare the LangOptions class
and initialize all of its members, eliminating a source of annoying
initialization bugs.

AST serialization changes are next up.

llvm-svn: 139605
2011-09-13 17:21:33 +00:00
Douglas Gregor 2b9b464290 When compiling a module on-demand, re-use the diagnostics client
already provided. This required a little bit of clean-up in the way
that VerifyDiagnosticsClient managed ownership of its underlying
"primary" client, because now it will no longer always take ownership.

llvm-svn: 139570
2011-09-13 01:26:44 +00:00
Douglas Gregor faeb1d4658 When an import statement fails to find a module in the module cache,
but there is a corresponding umbrella header in a framework, build the
module on-the-fly so it can be immediately loaded at the import
statement. This is very much proof-of-concept code, with details to be
fleshed out over time.

llvm-svn: 139558
2011-09-12 23:31:24 +00:00
Douglas Gregor 1e44e02292 Introduce a cc1-level option to provide the path to the module cache,
where the compiler will look for module files. Eliminates the
egregious hack where we looked into the header search paths for
modules.

llvm-svn: 139538
2011-09-12 20:41:59 +00:00
Argyrios Kyrtzidis 14c32e8894 [libclang] In ASTUnit::Parse copy the CompilerInvocation object instead of
modifying directly for the preamble.

This avoids an awful, hard to find, bug where "PreprocessorOpts.DisablePCHValidation = true"
would be persistent for subsequent reparses of the translation unit which would result
in defines, present in command-line but not in the PCH, being ignored.

Fixes rdar://9615399.

llvm-svn: 139512
2011-09-12 18:09:38 +00:00
Douglas Gregor b63ab9477c Only predefine the __EXCEPTIONS macro if C++ exceptions are turned on.
Only predefine the OBJC_ZEROCOST_EXCEPTIONS macro if Objective-C
exceptions are turned on. Fixes PR10910.

llvm-svn: 139496
2011-09-12 15:17:19 +00:00
Douglas Gregor 98c05b286c Kill of the Decl::PCHLevel field entirely. We now only need to know
whether a Decl was deserialized from an AST file (any AST file).

llvm-svn: 139438
2011-09-10 00:09:20 +00:00
John McCall 7959fee258 Treat the weak export of block runtime symbols as a deployment-target
feature akin to the ARC runtime checks.  Removes a terrible hack where
IR gen needed to find the declarations of those symbols in the translation
unit.

llvm-svn: 139404
2011-09-09 20:41:01 +00:00
Chandler Carruth 3d45b23dfc Extract the emission of the diagnostic's location into a separate
function. This is really the beginning of the second phase of
refactorings here. The end goal is to have (roughly) three interfaces:

1) Base class to format a single diagnostic suitable for display on the
   console.
2) Extension of the base class which also displays a caret diagnostic
   suitable for display on the console.
3) An adaptor that implements the DiagnosticClient by delegating to #1
   and/or #2 as appropriate.

Once we have these, things like libclang's formatDiagnostic can use #1
and #2 to provide really well formatted (and consistently formatted!)
textual formatting of diagnostics.

Getting there is going to be quite a bit of shuffling. I'm basically
sketching out where the interface boundaries can be drawn for #1 and #2
within the existing classes. That lets me shuffle with a minimum of fuss
and delta. Once that's done, and any of the related interfaces that need
to change are updated, I'll hoist these into separate headers and
re-implement libclang in terms of their interfaces. Long WIP, but
comments at each step welcome. =D

llvm-svn: 139228
2011-09-07 08:05:58 +00:00
Chandler Carruth 9779830513 Move the HilightRange method from TextDiagnosticPrinter down to
CaretDiagnostic. It's completely generic, with nothing to do with the
diagnostic client or info APIs.

llvm-svn: 139227
2011-09-07 07:02:31 +00:00
Chandler Carruth e79ddf8c67 Hoist the tab expansion into a helper function.
llvm-svn: 139226
2011-09-07 05:36:50 +00:00
Chandler Carruth 0f1006a95a Don't compute the same line number in two places, once inside a loop.
llvm-svn: 139225
2011-09-07 05:01:10 +00:00
Chandler Carruth 773757a962 Switch the CharSourceRange array to a small vector. The array was
a stack array of a magical size with an assert() that we never
overflowed it. That seems incredibly risky. We also have a very nice API
for bundling up a vector we expect to usually have a small size without
loss of functionality or security if the size is excessive.

The fallout is to remove the last pointer+size parameter pair that are
traced through the recursive caret diagnostic emission.

llvm-svn: 139217
2011-09-07 01:47:09 +00:00
Chandler Carruth cf57ebfd4c Remove the doxyment for this now defunct parameter.
llvm-svn: 139197
2011-09-06 22:34:36 +00:00
Chandler Carruth 935574de2f Don't recompute the presumed loc twice in 5 lines of code... Spotted by
inspection.

llvm-svn: 139196
2011-09-06 22:34:33 +00:00
Chandler Carruth 1f28e6c7e3 Use ArrayRef for the fixit hint array rather than a pointer and a size.
Clean up loops over the hints to use the more idiomatic iterator form in
LLVM and Clang.

llvm-svn: 139195
2011-09-06 22:31:44 +00:00
Chandler Carruth 20bfaa0f68 Hoist the construction of the FixItHint line into a member function with
a defined interface. This isn't as nice as the previous one, but should
get better as I push through better data types in all these functions.

Also, I'm hoping to pull some aspects of this out into a common routine
(such as tab expansion).

Again, WIP, comments welcome as I'm going through.

llvm-svn: 139190
2011-09-06 22:01:04 +00:00
Peter Collingbourne 2e8201422d Add missing dependency
Spotted by Ninja.

llvm-svn: 139129
2011-09-06 02:08:40 +00:00
Argyrios Kyrtzidis a3deaeeb52 Fix Lexer::ComputePreamble when MaxLines parameter is non-zero.
The function was only counting lines that included tokens and not empty lines,
but MaxLines (mainly initiated to the line where the code-completion point resides)
is a count of overall lines (even empty ones).

llvm-svn: 139085
2011-09-04 03:32:04 +00:00