summaryrefslogtreecommitdiffstats
path: root/clang/lib/Frontend/PrintPreprocessedOutput.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Remove trailing spaceFangrui Song2018-07-301-6/+6
| | | | | | sed -Ei 's/[[:space:]]+$//' include/**/*.{def,h,td} lib/**/*.{cpp,h} llvm-svn: 338291
* Reland '[clang] Adding CharacteristicKind to PPCallbacks::InclusionDirective'Julie Hockett2018-05-101-10/+13
| | | | | | | | | | | | | | This commit relands r331904. Adding a SrcMgr::CharacteristicKind parameter to the InclusionDirective in PPCallbacks, and updating calls to that function. This will be useful in https://reviews.llvm.org/D43778 to determine which includes are system headers. Differential Revision: https://reviews.llvm.org/D46614 llvm-svn: 332021
* Revert "[clang] Adding CharacteristicKind to PPCallbacks::InclusionDirective"Julie Hockett2018-05-091-13/+10
| | | | | | This reverts commit r331904 because of a memory leak. llvm-svn: 331932
* [clang] Adding CharacteristicKind to PPCallbacks::InclusionDirectiveJulie Hockett2018-05-091-10/+13
| | | | | | | | | | | Adding a SrcMgr::CharacteristicKind parameter to the InclusionDirective in PPCallbacks, and updating calls to that function. This will be useful in https://reviews.llvm.org/D43778 to determine which includes are system headers. Differential Revision: https://reviews.llvm.org/D46614 llvm-svn: 331904
* Calculate size of buffer instead of using a magic value.Paul Robinson2018-01-031-1/+1
| | | | | | | | Patch by Matthew Davis! Differential Revision: https://reviews.llvm.org/D41421 llvm-svn: 321757
* Don't print end-of-directive tokens in -E outputReid Kleckner2017-10-161-0/+6
| | | | | | | | | | This comes up when pre-processing standalone .s files containing hash-prefixed comments. The pre-processor should skip the unknown directive and not emit an extra newline as we were doing. Fixes PR34950 llvm-svn: 315953
* [Preprocessor] Preserve #pragma clang assume_nonnull in preprocessed outputEli Friedman2017-09-271-0/+18
| | | | | | | | Patch by Zbigniew Sarbinowski! Differential Revision: https://reviews.llvm.org/D37861 llvm-svn: 314364
* [NFC] Refactor the Preprocessor function that handles Macro definitions and ↵Faisal Vali2017-07-171-2/+2
| | | | | | | | | | | | | | | | | rename Arguments to Parameters in Macro Definitions. - Extracted the reading of the tokens out into a separate function. - Replace 'Argument' with 'Parameter' when referring to the identifiers of the macro definition (as opposed to the supplied arguments - MacroArgs - during the macro invocation). This is in preparation for submitting patches for review to implement __VA_OPT__ which will otherwise just keep lengthening the HandleDefineDirective function and making it less comprehensible. I will also directly update some extra clang tooling that is broken by the change from Argument to Parameter. Hopefully the bots will stay appeased. Thanks! llvm-svn: 308190
* Revert changes from my previous refactoring - will need to fix dependencies ↵Faisal Vali2017-07-171-2/+2
| | | | | | | | in clang's extra tooling (such as clang-tidy etc.). Sorry about that. llvm-svn: 308158
* [NFC] Refactor the Preprocessor function that handles Macro definitions and ↵Faisal Vali2017-07-171-2/+2
| | | | | | | | | | | | | | rename Arguments to Parameters in Macro Definitions. - Extracted the reading of the tokens out into a separate function. - Replace 'Argument' with 'Parameter' when referring to the identifiers of the macro definition (as opposed to the supplied arguments - MacroArgs - during the macro invocation). This is in preparation for submitting patches for review to implement __VA_OPT__ which will otherwise just keep lengthening the HandleDefineDirective function and making it less comprehensible. Thanks! llvm-svn: 308157
* Support non-identifier module names when preprocessing modules.Richard Smith2017-06-191-3/+3
| | | | llvm-svn: 305758
* Add #pragma clang module begin/end pragmas and generate them when ↵Richard Smith2017-05-041-3/+34
| | | | | | | | | | | | | | preprocessing a module. These pragmas are intended to simulate the effect of entering or leaving a file with an associated module. This is not completely implemented yet: declarations between the pragmas will not be attributed to the correct module, but macro visibility is already functional. Modules named by #pragma clang module begin must already be known to clang (in some module map that's either loaded or on the search path). llvm-svn: 302098
* Add pragma to perform module import and use it in -E output.Richard Smith2017-04-291-30/+37
| | | | | | | | | | | | | | | | | | | | | Many of our supported configurations support modules but do not have any first-class syntax to perform a module import. This leaves us with a problem: there is no way to represent the expansion of a #include that imports a module in the -E output for such languages. (We don't want to just leave it as a #include because that requires the consumer of the preprocessed source to have the same file system layout and include paths as the creator.) This patch adds a new pragma: #pragma clang module import MODULE.NAME.HERE that imports a module, and changes -E and -frewrite-includes to use it when rewriting a #include that maps to a module import. We don't make any attempt to use a native language syntax import if one exists, to get more consistent output. (If in the future, @import and #include have different semantics in some way, the pragma will track the #include semantics.) llvm-svn: 301725
* Remove leaking UnknownPragmaHandlers right after we are done with them.Vassil Vassilev2017-04-271-13/+27
| | | | | | | | | | | | | | | | The UnknownPragmaHandlers added by DoPrintPreprocessedInput conflict with the real PragmaHandlers from clang::Parser because they try to handle the same #pragma directives. This makes it impossible to use a Preprocessor (that was previously passed to DoPrintPreprocessedInput), as an Preprocessor for a clang::Parser instance which is what we currently do in cling. This patch removes the added UnknownPragmaHandler to avoid conflicts these conflicts and leave the PragmaHandlers of the Preprocessors in a the same state as before calling DoPrintPreprocessedInput. Patch by Raphael Isemann (D32486)! llvm-svn: 301563
* Revert "Revert "PPCallbacks::MacroUndefined, change signature and add test.""Vedant Kumar2017-04-261-2/+4
| | | | | | | This reverts commit r301469. It isn't needed with r301470, which fixes the API break introduced in the original commit. llvm-svn: 301472
* Revert "PPCallbacks::MacroUndefined, change signature and add test."Vedant Kumar2017-04-261-4/+2
| | | | | | | | 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
* PPCallbacks::MacroUndefined, change signature and add test.Frederich Munch2017-04-261-2/+4
| | | | | | | | | | | | | | | | 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
* [Preprocessor] Support for '-dI' flagBruno Cardoso Lopes2016-11-171-8/+26
| | | | | | | | | | | | | | | | | Re-introduce r285411. Implement the -dI as supported by GCC: Output ‘#include’ directives in addition to the result of preprocessing. This change aims to add this option, pass it through to the preprocessor via the options class, and when inclusions occur we output some information (+ test cases). Patch by Steve O'Brien! Differential Revision: https://reviews.llvm.org/D26089 llvm-svn: 287275
* Revert "[Preprocessor] Support for '-dI' flag"Bruno Cardoso Lopes2016-10-281-26/+8
| | | | | | | This reverts r285411. Tests failing on http://lab.llvm.org:8011/builders/clang-x86-windows-msvc2015/builds/141 llvm-svn: 285416
* [Preprocessor] Support for '-dI' flagBruno Cardoso Lopes2016-10-281-8/+26
| | | | | | | | | | | | | | | Implement the -dI as supported by GCC: Output ‘#include’ directives in addition to the result of preprocessing. This change aims to add this option, pass it through to the preprocessor via the options class, and when inclusions occur we output some information (+ test cases). Patch by Steve O'Brien! Differential Revision: https://reviews.llvm.org/D25153 llvm-svn: 285411
* [modules] Add a comment to explain why -E leaves some #includes in the ↵Richard Smith2016-04-081-1/+3
| | | | | | preprocessed output. llvm-svn: 265766
* [modules] Don't write @import in -E output if the current language mode doesn'tRichard Smith2016-04-081-2/+12
| | | | | | support @import; use the form as written instead. llvm-svn: 265756
* Remove use of builtin comma operator.Richard Trieu2016-02-181-2/+4
| | | | | | Cleanup for upcoming Clang warning -Wcomma. No functionality change intended. llvm-svn: 261271
* Reduce the number of implicit StringRef->std::string conversions by ↵Benjamin Kramer2016-02-131-12/+10
| | | | | | | | threading StringRef through more APIs. No functionality change intended. llvm-svn: 260815
* Simplify EnterTokenStream API to make it more robust for memory managementDavid Blaikie2016-02-091-4/+3
| | | | | | | | | | | | | | | While this won't help fix things like the bug that r260219 addressed, it seems like good tidy up to have anyway. (it might be nice if "makeArrayRef" always produced a MutableArrayRef & let it decay to an ArrayRef when needed - then I'd use that for the MutableArrayRefs in this patch) If we had std::dynarray I'd use that instead of unique_ptr+size_t, ideally (but then it'd have to be threaded down through the Preprocessor all the way - no idea how painful that would be) llvm-svn: 260246
* Fix possible OOB access found by buildbotAlexey Bataev2016-02-091-7/+8
| | | | llvm-svn: 260219
* Fixed preprocessed output of the first token for pragmas.Alexey Bataev2016-02-091-0/+9
| | | | | | | Clang did not expanded macros in the very first token of the pragmas during preprocessed output llvm-svn: 260211
* According to the OpenMP spec, all the preprocessor macros should be Samuel Antao2015-06-151-10/+42
| | | | | | expanded in OpenMP pragmas. This patch adds support for that in -E. llvm-svn: 239784
* Replace a few std::string& with StringRef. NFC.Rafael Espindola2015-06-011-3/+3
| | | | | | Patch by Косов Евгений! llvm-svn: 238774
* Refactor MacroInfo so range for loops can be used to iterate its tokens.Daniel Marjamaki2015-05-111-4/+3
| | | | | | Differential Revision: http://reviews.llvm.org/D9079 llvm-svn: 236975
* Switch PPCallbacks to take the new MacroDefinition instead of ↵Richard Smith2015-05-041-2/+2
| | | | | | MacroDirective*, in order to preserve full information on module macro expansion. llvm-svn: 236404
* [modules] Stop trying to fake up a linear MacroDirective history.Richard Smith2015-04-291-3/+3
| | | | | | | | | | | | | | 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
* [modules] Determine the set of macros exported by a submodule at the end of ↵Richard Smith2015-04-231-1/+2
| | | | | | | | | | | 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
* Add -fuse-line-directive flag to control usage of #line with -EReid Kleckner2015-02-261-13/+9
| | | | | | | | | | | | | | | | | | Currently -fms-extensions controls this behavior, which doesn't make much sense. It means we can't identify what is and isn't a system header when compiling our own preprocessed output, because #line doesn't represent this information. If someone is feeding Clang's preprocessed output to another compiler, they can use this flag. Fixes PR20553. Reviewers: rsmith Differential Revision: http://reviews.llvm.org/D5217 llvm-svn: 230587
* 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
OpenPOWER on IntegriCloud