aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Frontend/PrintPreprocessedOutput.cpp
AgeCommit message (Collapse)AuthorFilesLines
2017-06-19Support non-identifier module names when preprocessing modules.Richard Smith1-3/+3
llvm-svn: 305758
2017-05-04Add #pragma clang module begin/end pragmas and generate them when ↵Richard Smith1-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
2017-04-29Add pragma to perform module import and use it in -E output.Richard Smith1-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
2017-04-27Remove leaking UnknownPragmaHandlers right after we are done with them.Vassil Vassilev1-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
2017-04-26Revert "Revert "PPCallbacks::MacroUndefined, change signature and add test.""Vedant Kumar1-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
2017-04-26Revert "PPCallbacks::MacroUndefined, change signature and add test."Vedant Kumar1-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
2017-04-26PPCallbacks::MacroUndefined, change signature and add test.Frederich Munch1-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
2016-11-17[Preprocessor] Support for '-dI' flagBruno Cardoso Lopes1-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
2016-10-28Revert "[Preprocessor] Support for '-dI' flag"Bruno Cardoso Lopes1-26/+8
This reverts r285411. Tests failing on http://lab.llvm.org:8011/builders/clang-x86-windows-msvc2015/builds/141 llvm-svn: 285416
2016-10-28[Preprocessor] Support for '-dI' flagBruno Cardoso Lopes1-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
2016-04-08[modules] Add a comment to explain why -E leaves some #includes in the ↵Richard Smith1-1/+3
preprocessed output. llvm-svn: 265766
2016-04-08[modules] Don't write @import in -E output if the current language mode doesn'tRichard Smith1-2/+12
support @import; use the form as written instead. llvm-svn: 265756
2016-02-18Remove use of builtin comma operator.Richard Trieu1-2/+4
Cleanup for upcoming Clang warning -Wcomma. No functionality change intended. llvm-svn: 261271
2016-02-13Reduce the number of implicit StringRef->std::string conversions by ↵Benjamin Kramer1-12/+10
threading StringRef through more APIs. No functionality change intended. llvm-svn: 260815
2016-02-09Simplify EnterTokenStream API to make it more robust for memory managementDavid Blaikie1-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
2016-02-09Fix possible OOB access found by buildbotAlexey Bataev1-7/+8
llvm-svn: 260219
2016-02-09Fixed preprocessed output of the first token for pragmas.Alexey Bataev1-0/+9
Clang did not expanded macros in the very first token of the pragmas during preprocessed output llvm-svn: 260211
2015-06-15According to the OpenMP spec, all the preprocessor macros should be Samuel Antao1-10/+42
expanded in OpenMP pragmas. This patch adds support for that in -E. llvm-svn: 239784
2015-06-01Replace a few std::string& with StringRef. NFC.Rafael Espindola1-3/+3
Patch by Косов Евгений! llvm-svn: 238774
2015-05-11Refactor MacroInfo so range for loops can be used to iterate its tokens.Daniel Marjamaki1-4/+3
Differential Revision: http://reviews.llvm.org/D9079 llvm-svn: 236975
2015-05-04Switch PPCallbacks to take the new MacroDefinition instead of ↵Richard Smith1-2/+2
MacroDirective*, in order to preserve full information on module macro expansion. llvm-svn: 236404
2015-04-29[modules] Stop trying to fake up a linear MacroDirective history.Richard Smith1-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
2015-04-23[modules] Determine the set of macros exported by a submodule at the end of ↵Richard Smith1-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
2015-02-26Add -fuse-line-directive flag to control usage of #line with -EReid Kleckner1-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
2014-09-10Avoid a couple of assertions when preprocessing with modulesBen Langmuir1-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
2014-09-10Unique_ptrify PPCallbacks ownership.Craig Topper1-1/+1
Unique_ptr creation stil needs to be moved earlier at some of the call sites. llvm-svn: 217474
2014-06-12Complete the switch from mappings to declarative diagnostic severitiesAlp Toker1-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
2014-06-10Improve diagnostic mapping terminologyAlp Toker1-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
2014-05-22[C++11] Use 'nullptr'. Frontend edition.Craig Topper1-2/+3
llvm-svn: 209389
2014-05-01do not warn about unknown pragmas in modes that do not handle them (pr9537)Lubos Lunak1-1/+1
And refactor to have just one place in code that sets up the empty pragma handlers. llvm-svn: 207758
2014-03-13Remove unreachable PragmaCaptured method. It's not a real PPCallback.Craig Topper1-10/+0
llvm-svn: 203759
2014-03-13[C++11] Add 'override' keyword to virtual methods that override their base ↵Craig Topper1-31/+27
class. llvm-svn: 203758
2014-03-07[C++11] Revert uses of lambdas with array_pod_sort.Benjamin Kramer1-5/+6
Looks like GCC implements the lambda->function pointer conversion differently. llvm-svn: 203293
2014-03-07[C++11] Convert sort predicates into lambdas.Benjamin Kramer1-6/+5
No functionality change. llvm-svn: 203289
2014-02-28Add 'remark' diagnostic type in 'clang'Tobias Grosser1-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
2014-02-24If preprocessing results in a token with leading whitespace that was expandedRichard Smith1-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
2014-02-20Expand macros in pragmas with -fms-extensions and -EReid Kleckner1-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
2014-01-30Revert "Fix assertion failures on annot_* tokens in clang -E"Ben Langmuir1-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
2014-01-30Fix assertion failures on annot_* tokens in clang -EBen Langmuir1-5/+4
In particular, #pragma clang __debug, and #include implicitly changed into @import were causing assertion failures. llvm-svn: 200475
2013-12-04Revert r196372, "do not warn about unknown pragmas in modes that do not ↵NAKAMURA Takumi1-1/+1
handle them (pr9537)" It broke clang tests on some hosts with +Asserts. Seems "STDC" clashes. llvm-svn: 196376
2013-12-04do not warn about unknown pragmas in modes that do not handle them (pr9537)Lubos Lunak1-1/+1
And refactor to have just one place in code that sets up the empty pragma handlers. llvm-svn: 196372
2013-11-23Generate a marker token when entering or leaving a submodule when building aRichard Smith1-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
2013-11-15When we hit a #include directive that maps to a module import, emit a tokenRichard Smith1-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
2013-10-02Accept #pragma warning(push, 0) without warningReid Kleckner1-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
2013-09-22Fix array_pod_sort predicates after LLVM change.Benjamin Kramer1-3/+1
llvm-svn: 191176
2013-09-13Lex and ignore Microsoft's #pragma warning(...)Reid Kleckner1-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
2013-08-29Properly escape filenames in line directives.Eli Friedman1-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
2013-06-04Adding support for MSVC #pragma detect_mismatch functionality by emitting a ↵Aaron Ballman1-19/+30
FAILIFMISMATCH linker command into the object file. llvm-svn: 183178
2013-04-29When emitting a preprocessed file with implicit module imports, make sure ↵Argyrios Kyrtzidis1-0/+1
line directives are emitted in the next line. rdar://13722737 llvm-svn: 180718
2013-04-19Keep the parentheses in #pragma message (partial revert of r179771).Andy Gibbs1-1/+3
llvm-svn: 179862