Commit Graph

69 Commits

Author SHA1 Message Date
Vedant Kumar 349a624ab9 Revert "Revert "PPCallbacks::MacroUndefined, change signature and add test.""
This reverts commit r301469. It isn't needed with r301470, which fixes
the API break introduced in the original commit.

llvm-svn: 301472
2017-04-26 21:05:44 +00:00
Vedant Kumar 5e511ed49c Revert "PPCallbacks::MacroUndefined, change signature and add test."
This reverts commit r301449. It breaks the build with:

  MacroPPCallbacks.h:114:50: error: non-virtual member function marked 'override' hides virtual member function

llvm-svn: 301469
2017-04-26 20:58:19 +00:00
Frederich Munch b7755111a2 PPCallbacks::MacroUndefined, change signature and add test.
Summary:
The PPCallbacks::MacroUndefined callback is currently insufficient for clients that need to track the MacroDirectives.
This patch adds an additional argument to PPCallbacks::MacroUndefined that is the undef MacroDirective.

Reviewers: bruno, manmanren

Reviewed By: bruno

Subscribers: nemanjai, cfe-commits

Differential Revision: https://reviews.llvm.org/D29923

llvm-svn: 301449
2017-04-26 19:47:31 +00:00
Benjamin Kramer c3f89253ae Retire llvm::alignOf in favor of C++11 alignof.
No functionality change intended.

llvm-svn: 284730
2016-10-20 14:27:22 +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
Yaron Keren 8b563665c3 Replace double negation of !FileID.isInvalid() with FileID.isValid().
+couple more of double-negated !SourceLocation.isInvalid() unfixed in r249228.

llvm-svn: 249235
2015-10-03 10:46:20 +00:00
Alexander Kornienko ab9db51042 Revert r240270 ("Fixed/added namespace ending comments using clang-tidy").
llvm-svn: 240353
2015-06-22 23:07:51 +00:00
Alexander Kornienko 3d9d929e42 Fixed/added namespace ending comments using clang-tidy. NFC
The patch is generated using this command:

  $ tools/extra/clang-tidy/tool/run-clang-tidy.py -fix \
      -checks=-*,llvm-namespace-comment -header-filter='llvm/.*|clang/.*' \
      work/llvm/tools/clang

To reduce churn, not touching namespaces spanning less than 10 lines.

llvm-svn: 240270
2015-06-22 09:47:44 +00:00
Richard Smith 36bd40df72 Switch PPCallbacks to take the new MacroDefinition instead of MacroDirective*, in order to preserve full information on module macro expansion.
llvm-svn: 236404
2015-05-04 03:15:40 +00:00
Richard Smith 66a8186ed4 Rename MacroDefinition -> MacroDefinitionRecord, Preprocessor::MacroDefinition -> MacroDefinition.
clang::MacroDefinition now models the currently-defined value of a macro. The
previous MacroDefinition type, which represented a record of a macro definition
directive for a detailed preprocessing record, is now called MacroDefinitionRecord.

llvm-svn: 236400
2015-05-04 02:25:31 +00:00
Benjamin Kramer 15b9717873 Implement PreprocessingRecord's and LazyVector's iterators on top of iterator_adaptor_base
This basically creates a wrapper around an 'int' that poses as an iterator.
While that looks a bit counter-intuitive it works just fine because iterator
operations and basic integer arithmetic works in exactly the same way.

Remove the manual integer wrapping code and reduce the reliance on iterator
internals in the implementation. No functionality change intended.

llvm-svn: 232322
2015-03-15 15:27:19 +00:00
David Blaikie 7a3cbb2997 Simplify boolean expressions in clang with clang-tidy
Patch by Richard (legalize at xmission dot com).

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

llvm-svn: 231619
2015-03-09 02:02:07 +00:00
Benjamin Kramer b4ef66832d Update APIs that return a pair of iterators to return an iterator_range instead.
Convert uses of those APIs into ranged for loops. NFC.

llvm-svn: 228404
2015-02-06 17:25:10 +00:00
Craig Topper d2d442ca73 [C++11] Use 'nullptr'. Lex edition.
llvm-svn: 209083
2014-05-17 23:10:59 +00:00
Argyrios Kyrtzidis 9ef5775a94 [libclang] Record ranges skipped by the preprocessor and expose them with libclang.
Patch by Erik Verbruggen!

llvm-svn: 196487
2013-12-05 08:19:32 +00:00
John Thompson cda95fe72c Add SourceRange to PPCallbacks::Defined callback.
llvm-svn: 186707
2013-07-19 18:50:04 +00:00
Argyrios Kyrtzidis 37e48ff547 [Preprocessor] For the MacroExpands preprocessor callback, also pass the MacroArgs object that provides information about
the argument tokens for a function macro.

llvm-svn: 181065
2013-05-03 22:31:32 +00:00
Argyrios Kyrtzidis b6210dff97 [Preprocessor/Modules] Separate the macro directives kinds into their own MacroDirective's subclasses.
For each macro directive (define, undefine, visibility) have a separate object that gets chained
to the macro directive history. This has several benefits:

-No need to mutate a MacroDirective when there is a undefine/visibility directive. Stuff like
 PPMutationListener become unnecessary.
-No need to keep extra source locations for the undef/visibility locations for the define directive object
 (which is the majority of the directives)
-Much easier to hide/unhide a section in the macro directive history.
-Easier to track the effects of the directives across different submodules.

llvm-svn: 178037
2013-03-26 17:17:01 +00:00
Argyrios Kyrtzidis fead64be9b [preprocessor] Use MacroDirective in the preprocessor callbacks to make available the
full information about the macro (e.g if it was imported and where).

llvm-svn: 175978
2013-02-24 00:05:14 +00:00
Argyrios Kyrtzidis 832de9fcf1 [preprocessing record] Have the MacroDefinitions map point to the MacroDefinition object instead
its index in the preprocessed entities vector.

This is because the order of the entities in the vector can change in some (uncommon) cases.

llvm-svn: 175907
2013-02-22 18:35:59 +00:00
David Blaikie 05785d1622 Include llvm::Optional in clang/Basic/LLVM.h
Post-commit CR feedback from Jordan Rose regarding r175594.

llvm-svn: 175679
2013-02-20 22:23:23 +00:00
Argyrios Kyrtzidis 962b2210cc [preprocessing record] Add some sanity checks for the preprocessed entity index
to make sure we don't crash on release if the index is not valid.

rdar://13089714

llvm-svn: 175010
2013-02-12 21:41:23 +00:00
Argyrios Kyrtzidis 99b0a6a03a [preprocessor] Call the MacroUndefined callback even when the macro was not defined.
Patch by Enea Zaffanella!

llvm-svn: 172623
2013-01-16 16:52:44 +00:00
Argyrios Kyrtzidis eb994f4064 [PreprocessingRecord] A macro expansion can be reported out-of-order in cases when
there are macro expansions inside macro arguments where the arguments are
not expanded in the same order as listed; don't assert that all macro expansions
are in source order.

rdar://12397063

llvm-svn: 172018
2013-01-09 23:22:20 +00:00
Argyrios Kyrtzidis f77b0f8886 [libclang] Resolve a cursor that points to a macro name inside a #ifdef/#ifndef
directive as a macro expansion.

This is more of a "macro reference" than a macro expansion but it's close enough
for libclang's purposes. If it causes issues we can revisit and introduce a new
kind of cursor.

llvm-svn: 169666
2012-12-08 02:21:17 +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
Argyrios Kyrtzidis f3d587ea7c Refactor recording the preprocessor conditional directive regions out of
PreprocessingRecord and into its own class, PPConditionalDirectiveRecord.

Decoupling allows a client to use the functionality of PPConditionalDirectiveRecord
without needing a PreprocessingRecord.

llvm-svn: 169229
2012-12-04 07:27:05 +00:00
Argyrios Kyrtzidis d1c9031c91 In the PreprocessingRecord, to identify the different conditional directive regions
use the SourceLocation at the start of the respective region, instead of a unique integer.

llvm-svn: 169228
2012-12-04 07:26:53 +00:00
Argyrios Kyrtzidis abc721ab4d [preprocessing record] Have PPEntityID be independent of the size of the
loaded entities vector, otherwise its meaning will change when a module
is imported and the vector size changes.

llvm-svn: 165278
2012-10-05 00:22:28 +00:00
Argyrios Kyrtzidis f590e094ad Add info in the preprocessing record whether an inclusion directive
resulted in an automatic module import.

llvm-svn: 165022
2012-10-02 16:10:46 +00:00
Argyrios Kyrtzidis 19d78b743f For PPCallbacks::InclusionDirective() add a parameter for the module, whenever
an inclusion directive was automatically turned into a module import, and
PPCallbacks::moduleImport() for an explicit module import.

llvm-svn: 164874
2012-09-29 01:06:10 +00:00
Argyrios Kyrtzidis 4fcd2885de Per discussion in http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20120917/064551.html
have PPCallbacks::InclusionDirective pass the character range for the filename quotes or brackets.

rdar://11113134 & http://llvm.org/PR13880

llvm-svn: 164743
2012-09-27 01:42:07 +00:00
James Dennett 303d8d49ab Documentation cleanup:
* Use \p param for a parameter reference, not the (erroneous) form \arg param;
* Escape # characters in Doxygen comments as needed.

llvm-svn: 158971
2012-06-22 05:37:13 +00:00
Argyrios Kyrtzidis a956450eb7 [preprocessor] Handle correctly inclusion directives that have macro expansions, e.g
"#include MACRO(STUFF)".

-As an inclusion position for the included file, use the file location of the file where it
was included but *after* the macro expansions. We want the macro expansions to be considered
as before-in-translation-unit for everything in the included file.

-In the preprocessing record take into account that only inclusion directives can be encountered
as "out-of-order" (by comparing the start of the range which for inclusions is the hash location)
and use binary search if there is an extreme number of macro expansions in the include directive.

Fixes rdar://11111779

llvm-svn: 153527
2012-03-27 18:47:48 +00:00
Benjamin Kramer e894e09e70 Simplify some users of DenseMap::erase.
llvm-svn: 153389
2012-03-24 18:22:12 +00:00
Argyrios Kyrtzidis 647dcd80f0 [preprocessor] Enhance PreprocessingRecord to keep track of locations of conditional directives.
Introduce PreprocessingRecord::rangeIntersectsConditionalDirective() which returns
true if a given range intersects with a conditional directive block.

llvm-svn: 152018
2012-03-05 05:48:17 +00:00
Argyrios Kyrtzidis 335c5a42e9 Don't record nested macro expansions in the preprocessing record,
it can only bring pain when dealing with preprocessor abuse (see: boost).

rdar://10898986

llvm-svn: 151427
2012-02-25 02:41:16 +00:00
David Blaikie 8a40f700e6 Remove unreachable code in Clang. (replace with llvm_unreachable where appropriate or when GCC requires it)
llvm-svn: 148292
2012-01-17 06:56:22 +00:00
Argyrios Kyrtzidis 429ec024f8 [PCH] When visiting preprocessed entities, make it possible to avoid deserializing
preprocessed entities that are #included in the range that we are interested.

This is useful when we are interested in preprocessed entities of a specific file, e.g
when we are annotating tokens. There is also an optimization where we cache the last
result of PreprocessingRecord::getPreprocessedEntitiesInRange and we re-use it if
there is a call with the same range as before.

rdar://10313365

llvm-svn: 142887
2011-10-25 00:29:50 +00:00
Argyrios Kyrtzidis f37d0a61c0 Handle the case where preprocessor entities are not received in order,
fixes http://llvm.org/PR11120

llvm-svn: 141788
2011-10-12 17:36:33 +00:00
Argyrios Kyrtzidis e523e389b2 Do manual binary search for preprocessing entities because their end locations
may be unordered and MSVC's debug-mode doesn't like it.

llvm-svn: 140337
2011-09-22 21:17:02 +00:00
Benjamin Kramer 2e9d9cfc39 More MSVC9 unbreaking.
llvm-svn: 140256
2011-09-21 16:58:20 +00:00
Argyrios Kyrtzidis 45e8cf5732 [libclang] When pointing at a macro expansion inside a macro argument,
return a cursor for the inner macro.

llvm-svn: 140207
2011-09-20 23:27:33 +00:00
Argyrios Kyrtzidis 0d48fb89c0 The location of the name in MacroDefinition is the beginning of its range,
don't store an extra location for it.

llvm-svn: 140190
2011-09-20 22:14:48 +00:00
Argyrios Kyrtzidis a35c4441b3 Fix gcc build.
llvm-svn: 140073
2011-09-19 22:02:08 +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 64f6381097 Introduce PreprocessingRecord::getPreprocessedEntitiesInRange()
which will do a binary search and return a pair of iterators
for preprocessed entities in the given source range.

Source ranges of preprocessed entities are stored twice currently in
the PCH/Module file but this will be fixed in a subsequent commit.

llvm-svn: 140058
2011-09-19 20:40:25 +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
Argyrios Kyrtzidis 80f78b961a [libclang] Fix annotation and getting a "macro expansion" cursor
for a builtin macro expansion.

llvm-svn: 139298
2011-09-08 17:18:41 +00:00