Commit Graph

1598 Commits

Author SHA1 Message Date
Richard Smith daa69e00f5 [modules] Substantially improve handling of #undef:
* Track override set across module load and save
 * Track originating module to allow proper re-export of #undef
 * Make override set properly transitive when it picks up a #undef

This fixes nearly all of the remaining macro issues with self-host.

llvm-svn: 213922
2014-07-25 04:40:03 +00:00
Aaron Ballman 31f42318d8 Improving the "integer constant too large" diagnostics based on post-commit feedback from Richard Smith. Amends r213657.
llvm-svn: 213865
2014-07-24 14:51:23 +00:00
Richard Smith 73a29662b9 Simplify MacroInfo lifetime management. We don't need three different functions
to destroy one of these.

llvm-svn: 213837
2014-07-24 03:25:00 +00:00
Richard Smith ee0c4c1673 Remove unused Prev pointer from MacroInfo chain.
Remove pointless MICache: it only ever contained up to 1 object, and was only
non-empty when recovering from an error. There's no performance or memory win
from maintaining this cache.

llvm-svn: 213825
2014-07-24 01:13:23 +00:00
Ben Langmuir b537a3a651 Add stopgap option -fmodule-implementation-of <name>
This flag specifies that we are building an implementation file of the
module <name>, preventing importing <name> as a module. This does not
consider this to be the 'current module' for the purposes of doing
modular checks like decluse or non-modular-include warnings, unlike
-fmodule-name.

This is needed as a stopgap until:
1) we can resolve relative includes to a VFS-mapped module (or can
   safely import a header textually and as part of a module)

and ideally
2) we can safely do incremental rebuilding when implementation files
   import submodules.

llvm-svn: 213767
2014-07-23 15:30:23 +00:00
Aaron Ballman 446867ee4e Provide extra information in the "integer constant is too large" diagnostic. This will be used to improve other diagnostics.
llvm-svn: 213657
2014-07-22 14:08:09 +00:00
Richard Smith e657bbdcbc Reinstate r213348, reverted in r213395, with an additional bug fix and more
thorough tests.

Original commit message:

[modules] Fix macro hiding bug exposed if:

 * A submodule of module A is imported into module B
 * Another submodule of module A that is not imported into B exports a macro
 * Some submodule of module B also exports a definition of the macro, and
   happens to be the first submodule of B that imports module A.

In this case, we would incorrectly determine that A's macro redefines B's
macro, and so we don't need to re-export B's macro at all.

This happens with the 'assert' macro in an LLVM self-host. =(

llvm-svn: 213416
2014-07-18 22:13:40 +00:00
Richard Smith a5d2a49c34 Add dump() for MacroDirective and MacroInfo.
llvm-svn: 213349
2014-07-18 04:54:02 +00:00
Ben Langmuir 6b7f73451f Fix case-sensitivity of inferred framework modules
Just because we can open a directory named "COcoa.framework" doesn't
mean we should provide a "COcoa" module on a case-insensitive filesystem.

llvm-svn: 212975
2014-07-14 19:45:12 +00:00
David Blaikie 326ffb3683 Improve memory ownership of vfs::Files in the FileSystemStatCache by using std::unique_ptr
Spotted after a memory leak (due to the complexities of manual memory
management) was fixed in 212466.

llvm-svn: 212541
2014-07-08 15:46:02 +00:00
Alp Toker 2584735846 PTH: use a variable instead of a macro
Cleanup only.

llvm-svn: 212457
2014-07-07 14:01:37 +00:00
Rafael Espindola 2d2b420ab9 Update for llvm api change.
llvm-svn: 212408
2014-07-06 17:43:24 +00:00
Ben Langmuir e4f86bd851 Removed unused typedef for recursive_directory_iterator
llvm-svn: 212047
2014-06-30 16:10:15 +00:00
Craig Topper 9d5583ef0a Convert StringLiteralParser constructor to use ArrayRef instead of a pointer and count.
llvm-svn: 211763
2014-06-26 04:58:39 +00:00
Ben Langmuir 54cbc706b1 Make -Wincomplete-umbrella go through the VFS
By using vfs::recursive_directory_iterator, this warning will now fire
when some or all of a module's headers are from VFS mappings.

llvm-svn: 211746
2014-06-25 23:53:43 +00:00
Alp Toker ac4e8e5fca DiagnosticIDs: use diagnostic severities to simplify extension handling
llvm-svn: 211479
2014-06-22 21:58:33 +00:00
David Majnemer 65a407c2ce Lex: Use the correct types for MS integer suffixes
Something went wrong with r211426, it is an older version of this code
and should not have been committed.  It was reverted with r211434.

Original commit message:
We didn't properly implement support for the sized integer suffixes.
Suffixes like i16 were essentially ignored instead of mapping them to
the appropriately sized integer type.

This fixes PR20008.

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

llvm-svn: 211441
2014-06-21 18:46:07 +00:00
Rafael Espindola d46e4a2303 Revert "Lex: Use the correct types for MS integer suffixes"
This reverts commit r211426.

This broke the arm bots. The crash can be reproduced on X86 by running.
./bin/clang -cc1  -fsyntax-only -verify -fms-extensions ~/llvm/clang/test/Lexer/ms-extensions.c -triple arm-linux

llvm-svn: 211434
2014-06-21 12:39:25 +00:00
David Majnemer 252cbe25cb Lex: Use the correct types for MS integer suffixes
We didn't properly implement support for the sized integer suffixes.
Suffixes like i16 were essentially ignored instead of mapping them to
the appropriately sized integer type.

This fixes PR20008.

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

llvm-svn: 211426
2014-06-21 00:51:59 +00:00
Yaron Keren fdbb4a54d5 Fixed formatting.
llvm-svn: 211295
2014-06-19 19:12:02 +00:00
Alp Toker d4a3f0e894 Hide the concept of diagnostic levels from lex, parse and sema
The compilation pipeline doesn't actually need to know about the high-level
concept of diagnostic mappings, and hiding the final computed level presents
several simplifications and other potential benefits.

The only exceptions are opportunistic checks to see whether expensive code
paths can be avoided for diagnostics that are guaranteed to be ignored at a
certain SourceLocation.

This commit formalizes that invariant by introducing and using
DiagnosticsEngine::isIgnored() in place of individual level checks throughout
lex, parse and sema.

llvm-svn: 211005
2014-06-15 23:30:39 +00:00
Rafael Espindola 8a8e554adc Include system_error directly.
llvm-svn: 210802
2014-06-12 17:19:42 +00:00
Rafael Espindola c080917ec2 Replace llvm::error_code with std::error_code.
llvm-svn: 210780
2014-06-12 14:02:15 +00:00
Alp Toker d576e00b44 DiagnosticsEngine: update severity setters to new terminology
llvm-svn: 210764
2014-06-12 11:13:52 +00:00
Alp Toker 46df1c0db8 Complete the switch from mappings to declarative diagnostic severities
This begins to address cognitive dissonance caused by treating the Note
diagnostic level as a severity in the diagnostic engine.

No change in functionality.

llvm-svn: 210758
2014-06-12 10:15:20 +00:00
Alp Toker c726c367f4 Improve diagnostic mapping terminology
Diagnostic mappings are used to calculate the final severity of diagnostic
instances.

Detangle the implementation to reflect the terminology used in documentation
and bindings.

No change in functionality.

llvm-svn: 210518
2014-06-10 09:31:37 +00:00
Alp Toker 4f43e55408 Implement -Wdate-time preprocessor warning
This GCC warning is useful for validating reproducible builds
and might help when tracking down issues with modules too.

llvm-svn: 210511
2014-06-10 06:08:51 +00:00
Craig Topper 4b56692e30 [C++11] Use 'nullptr'.
llvm-svn: 210448
2014-06-09 02:04:02 +00:00
Alp Toker e03e9e15f2 Preprocessor: make C++ operator names as macro identifiers a compatible extension
With recent changes, this is now a compatible language extension and can be
safely enabled with -ms-extensions instead of requiring the full
-ms-compatibility MSVC drop-in mode. As such we can now also emit an extension
warning under -Wmicrosoft to help users port their code.

llvm-svn: 209978
2014-05-31 16:32:22 +00:00
Alp Toker c5d194fcd3 Preprocessor: recover gracefully when C++ operator names are used as macro identifiers
This failure mode shows up occasionally when users try to include C headers in
C++ projects or when porting from Windows. We might as well recover in the way
the user expected, thus avoiding confusing diagnostic messages at point of use.

llvm-svn: 209963
2014-05-31 03:38:17 +00:00
Alp Toker f33619cb51 Preprocessor: don't exit early in CheckMacroName()
The checks below can hypothetically apply to converted operator name
identifiers.

In practice there are no builtin macros etc. with those names so there's no
behavioural change to test.

llvm-svn: 209962
2014-05-31 03:38:08 +00:00
Peter Collingbourne efe09b4c65 Permit the "if" literal suffix with Microsoft extensions enabled.
Differential Revision: http://reviews.llvm.org/D3963

llvm-svn: 209859
2014-05-29 23:10:15 +00:00
Alexander Kornienko d3b4e08960 Remove limits on the number of fix-it hints and ranges in the DiagnosticsEngine.
Summary:
The limits on the number of fix-it hints and ranges attached to a
diagnostic are arbitrary and don't apply universally to all users of the
DiagnosticsEngine. The way the limits are enforced may lead to diagnostics
generating invalid sets of fixes. I suggest removing the limits, which will also
simplify the implementation.

Reviewers: rsmith

Reviewed By: rsmith

Subscribers: klimek, cfe-commits

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

llvm-svn: 209468
2014-05-22 19:56:11 +00:00
Alp Toker 6521ecc083 Provide an aka for the C++ operator name macro diagnostic
llvm-svn: 209322
2014-05-21 21:23:39 +00:00
Alp Toker b05e0b53b9 Preprocessor: support defined() with operator names for MS compatibility
Also flesh out missing tests, improve diagnostic QOI and fix a couple of corner
cases found in the process.

Fixes PR10606.

llvm-svn: 209276
2014-05-21 06:13:51 +00:00
Alp Toker 7755aff556 Remove historical Unicode TODOs
There's no immediate demand or plan to work on these.

llvm-svn: 209090
2014-05-18 18:37:59 +00:00
Craig Topper d2d442ca73 [C++11] Use 'nullptr'. Lex edition.
llvm-svn: 209083
2014-05-17 23:10:59 +00:00
Alp Toker 2d57cea256 Provide and use a safe Token::getRawIdentifier() accessor
llvm-svn: 209061
2014-05-17 04:53:25 +00:00
Alp Toker 6ac2cd01d2 Rename SourceManager::createFileIDForMemBuffer()
It makes more sense to just overload createFileID().

Gardening only.

llvm-svn: 209002
2014-05-16 17:23:01 +00:00
Ben Langmuir ef914b89b4 Use the virtual name of headers when searching for a module
When using the VFS, we want the virtual header location when searching
for a framework module, since that will be the one in the correct
directory structure for the module.

I'll add a regression test once I finish reducing the larger one I have.

llvm-svn: 208901
2014-05-15 16:20:33 +00:00
Richard Smith 6d54014144 PR19698, PR19674: enable __has_feature checks for cxx_generic_lambdas and
cxx_decltype_auto, and fix documentation of cxx_generic_lambdas and
cxx_init_captures to specify the right feature-check name.

llvm-svn: 208445
2014-05-09 21:08:59 +00:00
Nico Weber 5f5b94141c Don't leak MacroArgs when using code completion, PR19688.
MacroArgs are owned by TokenLexer, and when a TokenLexer is destroyed, it'll
call its MacroArgs's destroy() method.  destroy() only appends the MacroArg to
Preprocessor's MacroArgCache list, and Preprocessor's destructor then calls
deallocate() on all MacroArgs in that list.  This method then ends up freeing
the MacroArgs's memory.

In a code completion context, Parser::cutOffParsing() gets called when a code
completion token is hit, which changes the type of the current token to
tok::eof.  eof tokens aren't always ConsumeToken()ed, so
Preprocessor::HandleEndOfFile() isn't always called, and that function is
responsible for popping the macro stack.

Due to this, Preprocessor::CurTokenLexer can be non-NULL when
~Preprocessor runs.  It's a unique_ptr, so it ended up being destructed after
~Preprocessor completed, and its MacroArgs thus got added to the freelist after
the code freeing things on the freelist had already completed.  The fix is to
explicitly call reset() before the freelist processing happens.  (See the bug
for more notes.)

llvm-svn: 208438
2014-05-09 18:09:42 +00:00
Nico Weber 0e9da35c3d Wrap to 80 columns, no code change.
llvm-svn: 208386
2014-05-09 01:00:48 +00:00
Nico Weber 33b2d71cb8 Fix filename in file header comment more.
llvm-svn: 208381
2014-05-09 00:42:08 +00:00
Nico Weber a7d1619e84 Fix filename in file header comment.
llvm-svn: 208380
2014-05-09 00:39:59 +00:00
Ben Langmuir 46b02e3edd Remove -Wnon-modular-include
But keep -Wnon-modular-include-in-[framework-]module

This warning is too noisy and doesn't really indicate a problem for most
people.  Even though it would only really affect people using
-Weverything, that seems bad so remove it.

llvm-svn: 208345
2014-05-08 18:09:29 +00:00
Ben Langmuir 71e1a64f91 Add -Wnon-modular-include* options
Warn on non-modular includes in various contexts.

-Wnon-modular-include
 -Wnon-modular-include-in-module
  -Wnon-modular-include-in-framework-module

Where each group is a subgroup of those above it.

llvm-svn: 208004
2014-05-05 21:44:13 +00:00
Chandler Carruth 4d9c3df429 [leaks] Fix a leak recently introduced to the pragma handling. This
whole code would be better with std::unique_ptr managing the lifetimes
of the handlers, but I wanted to make a targeted fix to the leaks first.
With this change, all of the Clang preprocessor tests are leak free with
LSan.

llvm-svn: 207872
2014-05-02 21:44:48 +00:00
Alp Toker 9663780e35 Reformat code following Preprocessor constructor updates
Landing this separately to make the previous commits easy to follow at home.

llvm-svn: 207826
2014-05-02 03:43:38 +00:00
Alp Toker 1ae02f68be Factor TargetInfo pointer/DelayInitialization bool pair out of Preprocessor ctor
The Preprocessor::Initialize() function already offers a clear interface to
achieve this, further reducing the confusing number of states a newly
constructed preprocessor can have.

llvm-svn: 207825
2014-05-02 03:43:30 +00:00