summaryrefslogtreecommitdiffstats
path: root/clang/lib/Frontend/PrintPreprocessedOutput.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Avoid a couple of assertions when preprocessing with modulesBen Langmuir2014-09-101-0/+3
| | | | | | | | | | | | | | | | 1. We were hitting the NextIsPrevious assertion because we were trying to merge decl chains that were independent of each other because we had no Sema object to allow them to find existing decls. This is fixed by delaying loading the "preloaded" decls until Sema is available. 2. We were trying to get identifier info from an annotation token, which asserts. The fix is to special-case the module annotations in the preprocessed output printer. Fixed in a single commit because when you hit 1 you almost invariably hit 2 as well. llvm-svn: 217550
* Unique_ptrify PPCallbacks ownership.Craig Topper2014-09-101-1/+1
| | | | | | Unique_ptr creation stil needs to be moved earlier at some of the call sites. llvm-svn: 217474
* Complete the switch from mappings to declarative diagnostic severitiesAlp Toker2014-06-121-5/+5
| | | | | | | | | 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
* Improve diagnostic mapping terminologyAlp Toker2014-06-101-4/+5
| | | | | | | | | | | | 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
* [C++11] Use 'nullptr'. Frontend edition.Craig Topper2014-05-221-2/+3
| | | | llvm-svn: 209389
* do not warn about unknown pragmas in modes that do not handle them (pr9537)Lubos Lunak2014-05-011-1/+1
| | | | | | | And refactor to have just one place in code that sets up the empty pragma handlers. llvm-svn: 207758
* Remove unreachable PragmaCaptured method. It's not a real PPCallback.Craig Topper2014-03-131-10/+0
| | | | llvm-svn: 203759
* [C++11] Add 'override' keyword to virtual methods that override their base ↵Craig Topper2014-03-131-31/+27
| | | | | | class. llvm-svn: 203758
* [C++11] Revert uses of lambdas with array_pod_sort.Benjamin Kramer2014-03-071-5/+6
| | | | | | Looks like GCC implements the lambda->function pointer conversion differently. llvm-svn: 203293
* [C++11] Convert sort predicates into lambdas.Benjamin Kramer2014-03-071-6/+5
| | | | | | No functionality change. llvm-svn: 203289
* Add 'remark' diagnostic type in 'clang'Tobias Grosser2014-02-281-0/+3
| | | | | | | | | | | | | | | | | | | | | | | A 'remark' is information that is not an error or a warning, but rather some additional information provided to the user. In contrast to a 'note' a 'remark' is an independent diagnostic, whereas a 'note' always depends on another diagnostic. A typical use case for remark nodes is information provided to the user, e.g. information provided by the vectorizer about loops that have been vectorized. This patch provides the initial implementation of 'remarks'. It includes the actual definiton of the remark nodes, their printing as well as basic parameter handling. We are reusing the existing diagnostic parameters which means a remark can be enabled with normal '-Wdiagnostic-name' flags and can be upgraded to an error using '-Werror=diagnostic-name'. '-Werror' alone does not upgrade remarks. This patch is by intention minimal in terms of parameter handling. More experience and more discussions will most likely lead to further enhancements in the parameter handling. llvm-svn: 202475
* If preprocessing results in a token with leading whitespace that was expandedRichard Smith2014-02-241-0/+7
| | | | | | | from a macro in column 0, ensure that we print whitespace before it in the -E output. Patch by Harald van Dijk! llvm-svn: 202070
* Expand macros in pragmas with -fms-extensions and -EReid Kleckner2014-02-201-36/+7
| | | | | | | | | | | | | | gcc never expands macros in pragmas and MSVC always expands macros before processing pragmas. Clang usually allows macro expansion, except in a handful of pragmas, most of which are handled by the lexer. Also remove PPCallbacks for pragmas that are currently handled in the parser. Without a Parser, such as with clang -E, these callbacks would never be called. Fixes PR18576. llvm-svn: 201821
* Revert "Fix assertion failures on annot_* tokens in clang -E"Ben Langmuir2014-01-301-4/+5
| | | | | | | This is causing a failure in the msan buildbot that I am having trouble reproducing. Reverting until I can figure out what went wrong. llvm-svn: 200492
* Fix assertion failures on annot_* tokens in clang -EBen Langmuir2014-01-301-5/+4
| | | | | | | In particular, #pragma clang __debug, and #include implicitly changed into @import were causing assertion failures. llvm-svn: 200475
* Revert r196372, "do not warn about unknown pragmas in modes that do not ↵NAKAMURA Takumi2013-12-041-1/+1
| | | | | | | | handle them (pr9537)" It broke clang tests on some hosts with +Asserts. Seems "STDC" clashes. llvm-svn: 196376
* do not warn about unknown pragmas in modes that do not handle them (pr9537)Lubos Lunak2013-12-041-1/+1
| | | | | | | And refactor to have just one place in code that sets up the empty pragma handlers. llvm-svn: 196372
* Generate a marker token when entering or leaving a submodule when building aRichard Smith2013-11-231-1/+3
| | | | | | | | | 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
* When we hit a #include directive that maps to a module import, emit a tokenRichard Smith2013-11-151-0/+5
| | | | | | | | | | | | representing the module import rather than making the module immediately visible. This serves two goals: * It avoids making declarations in the module visible prematurely, if we walk past the #include during a tentative parse, for instance, and * It gives a diagnostic (although, admittedly, not a very nice one) if a header with a corresponding module is included anywhere other than at the top level. llvm-svn: 194782
* Accept #pragma warning(push, 0) without warningReid Kleckner2013-10-021-1/+1
| | | | | | | | This partially addresses PR17435, but it doesn't actually implement the pragma. If we implement it, we should map levels 1-4 to something like -Wall and level 0 to something like -w. llvm-svn: 191833
* Fix array_pod_sort predicates after LLVM change.Benjamin Kramer2013-09-221-3/+1
| | | | llvm-svn: 191176
* Lex and ignore Microsoft's #pragma warning(...)Reid Kleckner2013-09-131-0/+34
| | | | | | | | | | | | | | | | | Summary: This fixes PR17145 and avoids unknown pragma warnings. This change does not attempt to map MSVC warning numbers to clang warning flags. Perhaps in the future we will implement a mapping for some common subset of Microsoft warnings, but for now we don't. Reviewers: rsmith CC: cfe-commits Differential Revision: http://llvm-reviews.chandlerc.com/D1652 llvm-svn: 190726
* Properly escape filenames in line directives.Eli Friedman2013-08-291-3/+2
| | | | | | | Fixes PR17018. Only partial test coverage because I don't want to try to write a test which generates a file whose name contains a newline. llvm-svn: 189557
* Adding support for MSVC #pragma detect_mismatch functionality by emitting a ↵Aaron Ballman2013-06-041-19/+30
| | | | | | FAILIFMISMATCH linker command into the object file. llvm-svn: 183178
* When emitting a preprocessed file with implicit module imports, make sure ↵Argyrios Kyrtzidis2013-04-291-0/+1
| | | | | | | | line directives are emitted in the next line. rdar://13722737 llvm-svn: 180718
* Keep the parentheses in #pragma message (partial revert of r179771).Andy Gibbs2013-04-191-1/+3
| | | | llvm-svn: 179862
* Dropped the parentheses for #pragma message and its kin in the -E output ↵Andy Gibbs2013-04-181-5/+3
| | | | | | | | generator. This was a suggestion by Jordan Rose since the documented format for these pragmas is without the parentheses. At the same time, I've increased test coverage too for the preprocessed output. llvm-svn: 179771
* Fix off-by-one error in #pragma clang system_header.Jordan Rose2013-04-171-5/+6
| | | | | | | | | | | The system_header pragma (from GCC) is implemented using line notes in the source manager. However, a line note's line number specifies the number not for the current line, but for the next line. This was making all line numbers appear off by one after the pragma. Reported by Andy Gibbs, uncovered during r179677. llvm-svn: 179709
* Implemented #pragma GCC warning/error in the same mould as #pragma message.Andy Gibbs2013-04-171-4/+18
| | | | llvm-svn: 179687
* Sema for Captured StatementsTareq A. Siraj2013-04-161-0/+10
| | | | | | | | | | | | | Add CapturedDecl to be the DeclContext for CapturedStmt, and perform semantic analysis. Currently captures all variables by reference. TODO: templates Author: Ben Langmuir <ben.langmuir@intel.com> Differential Revision: http://llvm-reviews.chandlerc.com/D433 llvm-svn: 179618
* Parser support for #pragma clang __debug capturedTareq A. Siraj2013-04-161-0/+12
| | | | | | | | | | | | | | | This patch implements parsing ‘#pragma clang __debug’ as a first step for implementing captured statements. Captured statements are a mechanism for doing outlining in the AST. see http://lists.cs.uiuc.edu/pipermail/cfe-dev/2013-January/027540.html. Currently returns StmtEmpty Author: Andy Zhang <andy.zhang@intel.com> Differential Revision: http://llvm-reviews.chandlerc.com/D369 llvm-svn: 179614
* [frontend] When preprocessing, turn implicit module imports into @imports.Argyrios Kyrtzidis2013-04-101-0/+29
| | | | | | part of rdar://13610250 llvm-svn: 179144
* [Preprocessor/Modules] Separate the macro directives kinds into their own ↵Argyrios Kyrtzidis2013-03-261-2/+2
| | | | | | | | | | | | | | | | 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
* Preprocessor: don't keep comments under -traditional-cpp.Jordan Rose2013-03-051-1/+10
| | | | | | | | | | | This patch is designed for minimal intrusion into normal preprocessing and compilation; under -E -traditional-cpp, the lexer will still generate tok::comment nodes since it is preserving all whitespace, but the output printer will then throw it away. <rdar://problem/13338680> llvm-svn: 176534
* [preprocessor] Use MacroDirective in the preprocessor callbacks to make ↵Argyrios Kyrtzidis2013-02-241-4/+5
| | | | | | | | available the full information about the macro (e.g if it was imported and where). llvm-svn: 175978
* Preprocessor: preserve whitespace in -traditional-cpp mode.Jordan Rose2013-02-211-2/+2
| | | | | | | | | 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-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | 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-3/+3
| | | | | | | 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
* Fix the indentation of the first line of preprocessor outputHal Finkel2013-01-281-1/+5
| | | | | | | | | | The -E output from clang did not produce the correct indentation on the first line. This is because MoveToLine returned false, and when this happens, the regular process for producing initial indentation is skipped. Thanks to Eli for suggesting a way to simplify this to a one-line change. llvm-svn: 173657
* Constify argument of Preprocessor::getMacroInfoHistory and propagate toDmitri Gribenko2013-01-141-1/+1
| | | | | | callers, removing unneeded const_cast llvm-svn: 172372
* Make sure clang puts tokens from different files on separate lines in "-E ↵Eli Friedman2013-01-091-1/+4
| | | | | | | | -P" mode. <rdar://problem/12774044> llvm-svn: 171944
* Sort all of Clang's files under 'lib', and fix up the broken headersChandler Carruth2012-12-041-2/+2
| | | | | | | | | | | | | 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
* CPP Output: Do not emit an enter file marker for the main file.Daniel Dunbar2012-11-161-0/+11
| | | | | | | | - This diverges from gcc, and confuses tools (like dtrace) which track # line markers as a way to determine which content is in the context of the main file. llvm-svn: 168128
* Keep history of macro definitions and #undefsAlexander Kornienko2012-08-291-2/+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
* Add missing cctype includes.Joerg Sonnenberger2012-08-101-0/+1
| | | | llvm-svn: 161660
* [-E] Emit a rewritten _Pragma on its own line.Jordan Rose2012-06-151-29/+36
| | | | | | | | | | | 1. Teach Lexer that pragma lexers are like macro expansions at EOF. 2. Treat pragmas like #define/#undef when printing. 3. If we just printed a directive, add a newline before any more tokens. (4. Miscellaneous cleanup in PrintPreprocessedOutput.cpp) PR10594 and <rdar://problem/11562490> (two separate related problems) llvm-svn: 158571
* Unify naming of LangOptions variable/get function across the Clang stack ↵David Blaikie2012-03-111-1/+1
| | | | | | | | | | (Lex to AST). The member variable is always "LangOpts" and the member function is always "getLangOpts". Reviewed by Chris Lattner llvm-svn: 152536
* Revert my patches which removed Diagnostic.h includes by moving some ↵Benjamin Kramer2012-02-071-3/+3
| | | | | | | | | | | | | | | | | | operator overloads out of line. This seems to negatively affect compile time onsome ObjC tests (which use a lot of partial diagnostics I assume). I have to come up with a way to keep them inline without including Diagnostic.h everywhere. Now adding a new diagnostic requires a full rebuild of e.g. the static analyzer which doesn't even use those diagnostics. This reverts commit 6496bd10dc3a6d5e3266348f08b6e35f8184bc99. This reverts commit 7af19b817ba964ac560b50c1ed6183235f699789. This reverts commit fdd15602a42bbe26185978ef1e17019f6d969aa7. This reverts commit 00bd44d5677783527d7517c1ffe45e4d75a0f56f. This reverts commit ef9b60ffed980864a8db26ad30344be429e58ff5. llvm-svn: 150006
* Basic: import SmallString<> into clang namespaceDylan Noblesmith2012-02-051-2/+2
| | | | | | | (I was going to fix the TODO about DenseMap too, but that would break self-host right now. See PR11922.) llvm-svn: 149799
* Remove Diagnostic.h include from Preprocessor.h.Benjamin Kramer2012-02-041-3/+3
| | | | | | | - Move the offending methods out of line and fix transitive includers. - This required changing an enum in the PPCallback API into an unsigned. llvm-svn: 149782
OpenPOWER on IntegriCloud