Commit Graph

121 Commits

Author SHA1 Message Date
Yaron Keren e02bcdca88 Remove spaces in empty line, NFC.
llvm-svn: 252405
2015-11-07 16:35:07 +00:00
Reid Kleckner 738d48d5fe Sink some PTHManager includes out of Preprocessor.h
This reduces the number of .cpp files needed to be rebuilt after
touching OnDiskHashTable from 120 to 21 for me.

llvm-svn: 251810
2015-11-02 17:53:55 +00:00
Angel Garcia Gomez 637d1e6694 Roll-back r250822.
Summary: It breaks the build for the ASTMatchers

Subscribers: klimek, cfe-commits

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

llvm-svn: 250827
2015-10-20 13:23:58 +00:00
Angel Garcia Gomez b5250d3448 Apply modernize-use-default to clang.
Summary: Replace empty bodies of default constructors and destructors with '= default'.

Reviewers: bkramer, klimek

Subscribers: klimek, alexfh, cfe-commits

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

llvm-svn: 250822
2015-10-20 12:52:55 +00:00
Richard Smith 4df6093ca3 [modules] Make sure macros get made visible in the top-level file if we've got
local submodule visibility enabled; that top-level file might not actually be
the module includes buffer if use of prebuilt modules is disabled.

llvm-svn: 241120
2015-06-30 21:29:55 +00:00
Douglas Gregor 2a20bd1a94 Introduced pragmas for audited nullability regions.
Introduce the clang pragmas "assume_nonnull begin" and "assume_nonnull
end" in which we make default assumptions about the nullability of many
unannotated pointers:

  - Single-level pointers are inferred to __nonnull
  - NSError** in a (function or method) parameter list is inferred to
    NSError * __nullable * __nullable.
  - CFErrorRef * in a (function or method) parameter list is inferred
    to CFErrorRef __nullable * __nullable.
  - Other multi-level pointers are never inferred to anything.

Implements rdar://problem/19191042.

llvm-svn: 240156
2015-06-19 18:25:57 +00:00
Richard Smith e520293c8b Avoid using a C++11 library feature not present in libstdc++4.7.
llvm-svn: 237872
2015-05-21 01:26:53 +00:00
Richard Smith 04765ae01e [modules] If we re-enter a submodule from within itself (when submodule
visibility is enabled) or leave and re-enter it, restore the macro and module
visibility state from last time we were in that submodule.

This allows mutually-#including header files to stand a chance at being
modularized with local visibility enabled.

llvm-svn: 237871
2015-05-21 01:20:10 +00:00
Richard Smith 2b63d15f49 [modules] Retain the name as written for umbrella headers and directories, rather than converting to an absolute path. No observable change expected, but this allows us to correctly compute the module for an umbrella header, which later changes will require.
llvm-svn: 237508
2015-05-16 02:28:53 +00:00
Richard Smith 4241314164 [modules] Add local submodule visibility support for declarations.
With this change, enabling -fmodules-local-submodule-visibility results in name
visibility rules being applied to submodules of the current module in addition
to imported modules (that is, names no longer "leak" between submodules of the
same top-level module). This also makes it much safer to textually include a
non-modular library into a module: each submodule that textually includes that
library will get its own "copy" of that library, and so the library becomes
visible no matter which including submodule you import.

llvm-svn: 237473
2015-05-15 20:05:43 +00:00
Richard Smith dbbc523639 [modules] Rearrange preprocessor module visibility handling, no observable change intended.
llvm-svn: 237331
2015-05-14 02:25:44 +00:00
Richard Smith 32dbd69ce2 [modules] Don't bother creating a ModuleMacro representing a #undef that overrides nothing.
llvm-svn: 236374
2015-05-02 01:14:40 +00:00
Richard Smith 38477db8c4 [modules] If a module #includes a modular header that #undef's its macro, it
should not export the macro.

... at least, not unless we have local submodule visibility enabled.

llvm-svn: 236369
2015-05-02 00:45:56 +00:00
Richard Smith ee977933f7 [modules] Add -fmodules-local-submodule-visibility flag.
This flag specifies that the normal visibility rules should be used even for
local submodules (submodules of the currently-being-built module). Thus names
will only be visible if a header / module that declares them has actually been
included / imported, and not merely because a submodule that happened to be
built earlier declared those names. This also removes the need to modularize
bottom-up: textually-included headers will be included into every submodule
that includes them, since their include guards will not leak between modules.

So far, this only governs visibility of macros, not of declarations, so is not
ready for real use yet.

llvm-svn: 236350
2015-05-01 21:22:17 +00:00
Richard Smith a7e2cc684f [modules] Start moving the module visibility information off the Module itself.
It has no place there; it's not a property of the Module, and it makes
restoring the visibility set when we leave a submodule more difficult.

llvm-svn: 236300
2015-05-01 01:53:09 +00:00
Richard Smith 20e883e59b [modules] Stop trying to fake up a linear MacroDirective history.
Modules builds fundamentally have a non-linear macro history. In the interest
of better source fidelity, represent the macro definition information
faithfully: we have a linear macro directive history within each module, and at
any point we have a unique "latest" local macro directive and a collection of
visible imported directives. This also removes the attendent complexity of
attempting to create a correct MacroDirective history (which we got wrong
in the general case).

No functionality change intended.

llvm-svn: 236176
2015-04-29 23:20:19 +00:00
Richard Smith 1e1728536a Refactor to make MacroState ownership and lifetime clearer.
llvm-svn: 236032
2015-04-28 21:05:07 +00:00
Richard Smith 753e007091 [modules] Incrementally compute the list of overridden module macros based on
the active module macros at the point of definition, rather than reconstructing
it from the macro history. No functionality change intended.

llvm-svn: 235941
2015-04-27 23:21:38 +00:00
David Majnemer b9ac794f57 Remove unused variable to silence GCC warning
llvm-svn: 235693
2015-04-24 04:14:25 +00:00
Richard Smith 6b77f549cb [modules] Partial revert of r235669: don't create ModuleMacros for imported local macros.
The surrounding infrastructure isn't quite ready for this yet.

llvm-svn: 235677
2015-04-24 00:41:09 +00:00
Richard Smith 50474bf5d2 [modules] Refactor creation of ModuleMacros and create them when importing from local submodules.
llvm-svn: 235669
2015-04-23 23:29:05 +00:00
Richard Smith 2a553089c3 [modules] Properly attribute macros to modules if they're in a file textually included into a file in the module.
llvm-svn: 235661
2015-04-23 22:58:06 +00:00
Richard Smith b8b2ed6529 [modules] Determine the set of macros exported by a submodule at the end of that submodule.
Previously we'd defer this determination until writing the AST, which doesn't
allow us to use this information when building other submodules of the same
module. This change also allows us to use a uniform mechanism for writing
module macro records, independent of whether they are local or imported.

llvm-svn: 235614
2015-04-23 18:18:26 +00:00
Ben Langmuir 6caebfda78 Remove superceded warning warn_forgotten_module_header
This DefaultIgnore warning under -Wincomplete-module was firing on
any module map files that happened to be parsed (it's only supposed to
fire on headers), and it has been superceded by
-Wnon-modular-include-in-module anyway.

For compatibility, I rewired -Wincomplete-module to imply
-Wnon-modular-include-in-module.

llvm-svn: 221357
2014-11-05 16:43:18 +00:00
Richard Smith 306d892076 [modules] Add support for 'textual header' directives.
This allows a module to specify that it logically contains a file, but that
said file is non-modular and intended for textual inclusion. This allows
layering checks to work properly in the presence of such files.

llvm-svn: 220448
2014-10-22 23:50:56 +00:00
Richard Smith bdf54a21b5 PR18793: If we try to EnterTokenStream when our current lexer is a caching
lexer, add the token buffer underneath the caching lexer where possible and
push the tokens directly into the caching lexer otherwise. We previously
put the lexer into a corrupted state where we could not guarantee to provide
the tokens in the right order and would sometimes assert.

llvm-svn: 218333
2014-09-23 21:05:52 +00:00
David Blaikie 6d5038c19c unique_ptrify Preprocessor's TokenLexerCache
llvm-svn: 216756
2014-08-29 19:36:52 +00:00
Ben Langmuir e4f86bd851 Removed unused typedef for recursive_directory_iterator
llvm-svn: 212047
2014-06-30 16:10:15 +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 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 c080917ec2 Replace llvm::error_code with std::error_code.
llvm-svn: 210780
2014-06-12 14:02:15 +00:00
Craig Topper d2d442ca73 [C++11] Use 'nullptr'. Lex edition.
llvm-svn: 209083
2014-05-17 23:10:59 +00:00
Argyrios Kyrtzidis 9ef53ceb51 [Preprocessor/CodeComplete] Don't add include guard macros to code-completion results.
llvm-svn: 205917
2014-04-09 18:21:23 +00:00
Argyrios Kyrtzidis 8ed7414e58 [Preprocessor] Only check for -Wunused-macros if the translation unit kind is TU_Complete.
llvm-svn: 203360
2014-03-08 21:18:26 +00:00
Ahmed Charles 9a16beb8bc Change OwningPtr::take() to OwningPtr::release().
This is a precursor to moving to std::unique_ptr.

llvm-svn: 203275
2014-03-07 19:33:25 +00:00
Argyrios Kyrtzidis e1974dcd92 [Preprocessor] Pass TranslationUnitKind to the preprocessor and if it is TU_Prefix
avoid warning for unused macros.

rdar://15034698

llvm-svn: 203213
2014-03-07 07:47:58 +00:00
Richard Smith 67294e253e Track the currently-being-built submodule inside the preprocessor (rather than
just storing a flag indicating if there was one), and include it in the 'end of
module' annotation. No functionality change.

llvm-svn: 200573
2014-01-31 20:47:44 +00:00
Richard Smith 34f30516aa Generate a marker token when entering or leaving a submodule when building a
module. Use the marker to diagnose cases where we try to transition between
submodules when not at the top level (most likely because a closing brace was
missing at the end of a header file, but is also possible if submodule headers
attempt to do something fundamentally non-modular, like our .def files).

llvm-svn: 195543
2013-11-23 04:06:09 +00:00
Ismail Pazarbasi 8d0f2f3ae3 Relax header guard mismatch warning with edit distance heuristic.
If the edit distance between the two macros is more than 50%, DefinedMacro may not be header guard or can be header guard of another header file or it might be defining something completely different set by the build environment.

llvm-svn: 192547
2013-10-12 23:17:37 +00:00
Eli Friedman 0834a4b901 Make Preprocessor::Lex non-recursive.
Before this patch, Lex() would recurse whenever the current lexer changed (e.g.
upon entry into a macro). This patch turns the recursion into a loop: the
various lex routines now don't return a token when the current lexer changes,
and at the top level Preprocessor::Lex() now loops until it finds a token.
Normally, the recursion wouldn't end up being very deep, but the recursion depth
can explode in edge cases like a bunch of consecutive macros which expand to
nothing (like in the testcase test/Preprocessor/macro_expand_empty.c in this
patch).

<rdar://problem/14569770>

llvm-svn: 190980
2013-09-19 00:41:32 +00:00
Richard Trieu 33a4b3db0d Introducing -Wheader-guard, a warning that checks header guards actually work
properly.  This warning checks that the #ifndef and #define directives at
the beginning of a header refer to the same macro name.  Includes a fix-it
hint to correct the header guard.

llvm-svn: 183867
2013-06-12 21:20:57 +00:00
Rafael Espindola 552c169ed3 Include Path.h instead of PathV2.h.
I am about to move PathV2.h to Path.h.

llvm-svn: 183795
2013-06-11 22:15:02 +00:00
Douglas Gregor f4e76b864f Add -Wincomplete-module, which detects when a header is included from a module but isn't itself part of a module.
llvm-svn: 182263
2013-05-20 13:49:41 +00:00
David Blaikie 7d17010db5 Use only explicit bool conversion operator
The most common (non-buggy) case are where such objects are used as
return expressions in bool-returning functions or as boolean function
arguments. In those cases I've used (& added if necessary) a named
function to provide the equivalent (or sometimes negative, depending on
convenient wording) test.

DiagnosticBuilder kept its implicit conversion operator owing to the
prevalent use of it in return statements.

One bug was found in ExprConstant.cpp involving a comparison of two
PointerUnions (PointerUnion did not previously have an operator==, so
instead both operands were converted to bool & then compared). A test
is included in test/SemaCXX/constant-expression-cxx1y.cpp for the fix
(adding operator== to PointerUnion in LLVM).

llvm-svn: 181869
2013-05-15 07:37:26 +00:00
Douglas Gregor 8f1f3331dc Add the module name to the 'incomplete umbrella header' warning.
llvm-svn: 171497
2013-01-04 18:58:28 +00:00
Argyrios Kyrtzidis 9fd1571e7a [libclang] Fix crash when code-completing a macro invocation that
reached EOF and did not expand the argument into the source context.

llvm-svn: 170980
2012-12-22 04:48:10 +00:00
Chandler Carruth 3a02247dc9 Sort all of Clang's files under 'lib', and fix up the broken headers
uncovered.

This required manually correcting all of the incorrect main-module
headers I could find, and running the new llvm/utils/sort_includes.py
script over the files.

I also manually added quite a few missing headers that were uncovered by
shuffling the order or moving headers up to be main-module-headers.

llvm-svn: 169237
2012-12-04 09:13:33 +00:00
Richard Smith 5edd5830e1 Make preprocessor act in a GCC-compatible fashion when a macro is redefined
within its own argument list. The original definition is used for the immediate
expansion, but the new definition is used for any subsequent occurences within
the argument list or after the expansion.

llvm-svn: 162906
2012-08-30 13:38:46 +00:00
James Dennett 1244a0d632 Documentation cleanup: escape # characters in Doxygen comments as needed.
llvm-svn: 158970
2012-06-22 05:36:05 +00:00
Axel Naumann 2eb1d90fd8 From Vassil Vassilev:
Enable incremental parsing by the Preprocessor,
where more code can be provided after an EOF.
It mainly prevents the tearing down of the topmost lexer.
To be used like this:
PP.enableIncrementalProcessing();
while (getMoreSource()) {
  while (Parser.ParseTopLevelDecl(ADecl)) {...}
}
PP.enableIncrementalProcessing(false);

llvm-svn: 152914
2012-03-16 10:40:17 +00:00