summaryrefslogtreecommitdiffstats
path: root/clang/lib/Lex/PPDirectives.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Split isFromMainFile into two functions.Eli Friedman2013-08-221-1/+1
| | | | | | | | | Basically, isInMainFile considers line markers, and isWrittenInMainFile doesn't. Distinguishing between the two is useful when dealing with files which are preprocessed files or rewritten with -frewrite-includes (so we don't, for example, print useless warnings). llvm-svn: 188968
* Add option to disable module loading.Daniel Jasper2013-08-051-9/+12
| | | | | | | This patch was created by Lawrence Crowl and reviewed in: http://llvm-reviews.chandlerc.com/D963 llvm-svn: 187738
* Added preproc callback for pragma directives.Enea Zaffanella2013-07-201-1/+1
| | | | llvm-svn: 186770
* Add condition expression result to if and elif callbacks.John Thompson2013-07-181-3/+5
| | | | llvm-svn: 186547
* Don't give # and ## special treatment when in -traditional-cpp mode. Patch byRichard Smith2013-07-091-0/+12
| | | | | | Austin Seipp! llvm-svn: 185896
* This patch adds new private headers to the module map. PrivateLawrence Crowl2013-06-201-9/+36
| | | | | | | headers may be included from within the module, but not from outside the module. llvm-svn: 184471
* Make sure the assembler-with-cpp hack for "#" works with multiple "#"s inEli Friedman2013-06-181-0/+2
| | | | | | succession. Fixes PR16363. llvm-svn: 184240
* PR16339: Don't produce a diagnostic pointing at the whitespace between a '#if'Richard Smith2013-06-161-1/+2
| | | | | | | | and a '!defined(X)' if we find a broken header guard. This is suboptimal; we should point the diagnostic at the 'X' token not the 'if' token, but it fixes the crash. llvm-svn: 184054
* Introducing -Wheader-guard, a warning that checks header guards actually workRichard Trieu2013-06-121-4/+14
| | | | | | | | 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
* [modules] If we hit a failure while loading a PCH/module, abort parsing ↵Argyrios Kyrtzidis2013-05-241-0/+14
| | | | | | | | | | instead of trying to continue in an invalid state. Also don't let libclang create a PCH with such an error. Fixes rdar://13953768 llvm-svn: 182629
* Use only explicit bool conversion operatorDavid Blaikie2013-05-151-1/+1
| | | | | | | | | | | | | | | | | | | 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
* [PCH] Fix memory leak related to deserialized MacroInfo objects.Argyrios Kyrtzidis2013-04-301-3/+6
| | | | | | | | | Deserialized MacroInfos were not destroyed and if their SmallVector did heap allocation, it was leaked. rdar://13768967 llvm-svn: 180771
* Improve the diagnostics of the number-reading preprocessor directives.Michael Ilseman2013-04-101-4/+6
| | | | | | | | | | | | | | The GNU line marker directive was sharing code with the #line directive, but some of the warnings/errors were reporting as #line directive diagnostics in both cases. Previously: #line 11foo1 ==> "#line directive requires a simple digit sequence" # 11foo1 ==> "#line directive requires a simple digit sequence" Now, we get: #line 11foo1 ==> "#line directive requires a simple digit sequence" # 11foo1 ==> "GNU line marker directive requires a simple digit sequence" llvm-svn: 179139
* [preprocessor] Allow comparing two macro definitions syntactically instead ↵Argyrios Kyrtzidis2013-04-031-2/+2
| | | | | | | | | | | | | | of only lexically. Syntactically means the function macro parameter names do not need to use the same identifiers in order for the definitions to be considered identical. Syntactic equivalence is a microsoft extension for macro redefinitions and we'll also use this kind of comparison to check for ambiguous macros coming from modules. rdar://13562254 llvm-svn: 178671
* [Preprocessor/Modules] Separate the macro directives kinds into their own ↵Argyrios Kyrtzidis2013-03-261-40/+30
| | | | | | | | | | | | | | | | 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
* [PCH/Modules] De/Serialize MacroInfos separately than MacroDirectives.Argyrios Kyrtzidis2013-03-221-13/+19
| | | | | | | | | -Serialize the macro directives history into its own section -Get rid of the macro updates section -When de/serializing an identifier from a module, associate only one macro per submodule that defined+exported it. llvm-svn: 177761
* [modules] When a MacroInfo object is deserialized, allocate and store its ↵Argyrios Kyrtzidis2013-03-221-0/+13
| | | | | | submodule ID. llvm-svn: 177760
* PR15539: Record "evaluating if/elif condition" flag in the right placeDavid Blaikie2013-03-181-2/+0
| | | | | | | The previous implementation missed the case where the elif condition was evaluated from the context of an #ifdef that was false causing PR15539. llvm-svn: 177345
* After issuing a diagnostic for undefining or redefining a builtin macro,Richard Smith2013-03-061-9/+12
| | | | | | | | | continue parsing the directive rather than silently discarding it. Allowing undef or redef of __TIME__ and __DATE__ is important to folks who want stable, reproducible builds. llvm-svn: 176540
* [preprocessor] Use MacroDirective in the preprocessor callbacks to make ↵Argyrios Kyrtzidis2013-02-241-6/+7
| | | | | | | | available the full information about the macro (e.g if it was imported and where). llvm-svn: 175978
* Preproceessor: fix #if skipping under -traditional-cpp.Jordan Rose2013-02-221-1/+1
| | | | | | | | | | | | When parsing directives within skipped #if blocks, we don't want to retain any whitespace. Previously we were just skipping comments, but it's not possible to skip comments and retain other whitespace. This change matches the usual behavior for parsing directives (i.e. the behavior outside of skipped #if blocks). <rdar://problem/13267695> llvm-svn: 175840
* Preprocessor: preserve whitespace in -traditional-cpp mode.Jordan Rose2013-02-211-9/+5
| | | | | | | | | Note that unlike GNU cpp we currently do not preserve whitespace in macros (even in -traditional-cpp mode). <rdar://problem/12897179> llvm-svn: 175778
* [preprocessor] Split the MacroInfo class into two separate concepts, ↵Argyrios Kyrtzidis2013-02-201-25/+28
| | | | | | | | | | | | | | | | | | | | | | | | | MacroInfo class for the data specific to a macro definition (e.g. what the tokens are), and MacroDirective class which encapsulates the changes to the "macro namespace" (e.g. the location where the macro name became active, the location where it was undefined, etc.) (A MacroDirective always points to a MacroInfo object.) Usually a macro definition (MacroInfo) is where a macro name becomes active (MacroDirective) but splitting the concepts allows us to better model the effect of modules to the macro namespace (also as a bonus it allows better modeling of push_macro/pop_macro #pragmas). Modules can have their own macro history, separate from the local (current translation unit) macro history; MacroDirectives will be used to model the macro history (changes to macro namespace). For example, if "@import A;" imports macro FOO, there will be a new local MacroDirective created to indicate that "FOO" became active at the import location. Module "A" itself will contain another MacroDirective in its macro history (at the point of the definition of FOO) and both MacroDirectives will point to the same MacroInfo object. Introducing the separation of macro concepts is the first part towards better modeling of module macros. llvm-svn: 175585
* Excise <cctype> from Clang (except clang-tblgen) in favor of CharInfo.h.Jordan Rose2013-02-081-1/+1
| | | | | | | Nearly all of these changes are one-to-one replacements; the few that aren't have to do with custom identifier validation. llvm-svn: 174768
* Teach subframework header lookup to suggest modules <rdar://problem/13176200>.Douglas Gregor2013-02-081-3/+4
| | | | llvm-svn: 174683
* [Lex] Remove DirectoryLookup.UserSpecified, which is unused.Daniel Dunbar2013-01-251-1/+1
| | | | llvm-svn: 173409
* Add some semantic checks for OpenCL. Variadic macros, VLAs and bitfields are ↵Joey Gouly2013-01-171-0/+6
| | | | | | not supported. llvm-svn: 172732
* No longer crashing with an assert when __has_include or __has_include_next ↵Aaron Ballman2013-01-161-0/+3
| | | | | | is used outside of a preprocessor directive. This fixes PR14837. llvm-svn: 172639
* [preprocessor] Call the MacroUndefined callback even when the macro was not ↵Argyrios Kyrtzidis2013-01-161-4/+5
| | | | | | | | defined. Patch by Enea Zaffanella! llvm-svn: 172623
* Remove useless 'llvm::' qualifier from names like StringRef and others that areDmitri Gribenko2013-01-121-1/+1
| | | | | | brought into 'clang' namespace by clang/Basic/LLVM.h llvm-svn: 172323
* s/CPlusPlus0x/CPlusPlus11/gRichard Smith2013-01-021-4/+4
| | | | llvm-svn: 171367
* Use @import rather than @__experimental_modules_import, since theDouglas Gregor2012-12-111-1/+1
| | | | | | latter is rather a mess to type. llvm-svn: 169919
* [Preprocessor] Enhance Ifdef/Ifndef/Defined preprocessor callbacks to also passArgyrios Kyrtzidis2012-12-081-2/+2
| | | | | | a MacroInfo object if the identifier was a macro name. llvm-svn: 169665
* Sort all of Clang's files under 'lib', and fix up the broken headersChandler Carruth2012-12-041-5/+5
| | | | | | | | | | | | | 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
* Keep track of modules that have failed to build. If we encounter anDouglas Gregor2012-11-291-1/+8
| | | | | | | | | | | | import of that module elsewhere, don't try to build the module again: it won't work, and the experience is quite dreadful. We track this information somewhat globally, shared among all of the related CompilerInvocations used to build modules on-the-fly, so that a particular Clang instance will only try to build a given module once. Fixes <rdar://problem/12552849>. llvm-svn: 168961
* Suppress elided variadic macro argument extension diagnostic for macros usingEli Friedman2012-11-141-1/+30
| | | | | | | | | | | | | | | | | | | | | | the related comma pasting extension. In certain cases, we used to get two diagnostics for what is essentially one extension. This change suppresses the first diagnostic in certain cases where we know we're going to print the second diagnostic. The diagnostic is redundant, and it can't be suppressed in the definition of the macro because it points at the use of the macro, so we want to avoid printing it if possible. The implementation works by detecting constructs which look like comma pasting at the time of the definition of the macro; this information is then used when the macro is used. (We can't actually detect whether we're using the comma pasting extension until the macro is actually used, but we can detecting constructs which will be comma pasting if the varargs argument is elided.) <rdar://problem/12292192> llvm-svn: 167907
* Make the FilenameRange of the InclusionDirective callback more accurate,Argyrios Kyrtzidis2012-11-011-2/+2
| | | | | | | | preserve the macro location of the range end if the filename came from a macro. Patch by Kim Gräsman! llvm-svn: 167239
* Rework the (de-)serialization of macros, as stored inDouglas Gregor2012-10-091-2/+14
| | | | | | | | | | | | | | | | MacroInfo*. Instead of simply dumping an offset into the current file, give each macro definition a proper ID with all of the standard modules-remapping facilities. Additionally, when a macro is modified in a subsequent AST file (e.g., #undef'ing a macro loaded from another module or from a precompiled header), provide a macro update record rather than rewriting the entire macro definition. This gives us greater consistency with the way we handle declarations, and ties together macro definitions much more cleanly. Note that we're still not actually deserializing macro history (we never were), but it's far easy to do properly now. llvm-svn: 165560
* For PPCallbacks::InclusionDirective() add a parameter for the module, wheneverArgyrios Kyrtzidis2012-09-291-5/+26
| | | | | | | an inclusion directive was automatically turned into a module import, and PPCallbacks::moduleImport() for an explicit module import. llvm-svn: 164874
* Add an assertion to make sure the implicitly imported moduleArgyrios Kyrtzidis2012-09-291-0/+2
| | | | | | is the same as the suggested one when looking up the include filename. llvm-svn: 164872
* Per discussion in ↵Argyrios Kyrtzidis2012-09-271-5/+3
| | | | | | | | | | 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
* [libclang] Fix getting a cursor inside an angled #include directive.Argyrios Kyrtzidis2012-09-111-0/+3
| | | | | | | | | Fixed by pointing the end location of the preprocessed entity for the #include at the closing '>', instead of the start of '<'. rdar://11113134 llvm-svn: 163588
* Fixed a problem with #pragma push_macro/pop_macro implementation.Alexander Kornienko2012-08-291-4/+1
| | | | | | | | | | | | | | | | | | | | Summary: The problem was with the following sequence: #pragma push_macro("long") #undef long #pragma pop_macro("long") in case when "long" didn't represent a macro. Fixed crash and removed code duplication for #undef/pop_macro case. Added regression tests. Reviewers: doug.gregor, klimek Reviewed By: doug.gregor CC: cfe-commits, chapuni Differential Revision: http://llvm-reviews.chandlerc.com/D31 llvm-svn: 162845
* Keep history of macro definitions and #undefsAlexander Kornienko2012-08-291-5/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Summary: Keep history of macro definitions and #undefs with corresponding source locations, so that we can later find out all macros active in a specified source location. We don't save the history in PCH (no need currently). Memory overhead is about sizeof(void*)*3*<number of macro definitions and #undefs>+<in-memory size of all #undef'd macros> I've run a test on a file composed of 109 .h files from boost 1.49 on x86-64 linux. Stats before this patch: *** Preprocessor Stats: 73222 directives found: 19171 #define. 4345 #undef. #include/#include_next/#import: 5233 source files entered. 27 max include stack depth 19210 #if/#ifndef/#ifdef. 2384 #else/#elif. 6891 #endif. 408 #pragma. 14466 #if/#ifndef#ifdef regions skipped 80023/451669/1270 obj/fn/builtin macros expanded, 85724 on the fast path. 127145 token paste (##) operations performed, 11008 on the fast path. Preprocessor Memory: 5874615B total BumpPtr: 4399104 Macro Expanded Tokens: 417768 Predefines Buffer: 8135 Macros: 1048576 #pragma push_macro Info: 0 Poison Reasons: 1024 Comment Handlers: 8 Stats with this patch: ... Preprocessor Memory: 7541687B total BumpPtr: 6066176 Macro Expanded Tokens: 417768 Predefines Buffer: 8135 Macros: 1048576 #pragma push_macro Info: 0 Poison Reasons: 1024 Comment Handlers: 8 In my test increase in memory usage is about 1.7Mb, which is ~28% of initial preprocessor's memory usage and about 0.8% of clang's total VMM allocation. As for CPU overhead, it should only be noticeable when iterating over all macros, and should mostly consist of couple extra dereferences and one comparison per macro + skipping of #undef'd macros. It's less trivial to measure, though, as the preprocessor consumes a very small fraction of compilation time. Reviewers: doug.gregor, klimek, rsmith, djasper Reviewed By: doug.gregor CC: cfe-commits, chandlerc Differential Revision: http://llvm-reviews.chandlerc.com/D28 llvm-svn: 162810
* Adding a fixit for includes that cannot be found with angle brackets, but ↵Aaron Ballman2012-07-171-3/+22
| | | | | | can be found with quoted strings instead. Implements PR13201. llvm-svn: 160406
* preprocessing: gcc supports #line 0. So, treat thisFariborz Jahanian2012-06-261-8/+4
| | | | | | | | as a gcc supported extension with usual treatment with -pedantic (warn) and -pedantic-errors (error). // rdar://11550996 llvm-svn: 159226
* Add testing for CommentHandler, and fix a bug where trailing comments in #elseRichard Smith2012-06-241-0/+8
| | | | | | | and #endif in non-skipped blocks were not passed to the CommentHandler. Patch by Andy Gibbs! llvm-svn: 159119
* Documentation cleanup:James Dennett2012-06-221-49/+56
| | | | | | | | | * Add \brief summaries; * Escape # characters in Doxygen comments; * Add \code...\endcode markup for code examples; * Add \verbatim...\endverbatim markup for grammar productions. llvm-svn: 158976
* Do not complain about junk on the end of a #endif in a skipped block. Such junkRichard Smith2012-06-211-1/+3
| | | | | | is permitted by all relevant language standards. Patch by Andy Gibbs! llvm-svn: 158883
* Add a -rewrite-includes option, which is similar to -rewrite-macros, but ↵David Blaikie2012-06-061-0/+19
| | | | | | | | | only expands #include directives. Patch contributed by Lubos Lunak (l.lunax@suse.cz). Review by Matt Beaumont-Gay (matthewbg@google.com). llvm-svn: 158093
OpenPOWER on IntegriCloud