summaryrefslogtreecommitdiffstats
path: root/clang/lib/Frontend/Rewrite
Commit message (Collapse)AuthorAgeFilesLines
* Port getLocEnd -> getEndLocStephen Kelly2018-08-092-30/+30
| | | | | | | | | | Reviewers: teemperor! Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D50351 llvm-svn: 339386
* Port getLocStart -> getBeginLocStephen Kelly2018-08-092-112/+111
| | | | | | | | | | Reviewers: teemperor! Subscribers: jholewinski, whisperity, jfb, cfe-commits Differential Revision: https://reviews.llvm.org/D50350 llvm-svn: 339385
* Remove trailing spaceFangrui Song2018-07-304-679/+679
| | | | | | 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-2/+4
| | | | | | | | | | | | | | 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-4/+2
| | | | | | This reverts commit r331904 because of a memory leak. llvm-svn: 331932
* [clang] Adding CharacteristicKind to PPCallbacks::InclusionDirectiveJulie Hockett2018-05-091-2/+4
| | | | | | | | | | | 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
* Remove \brief commands from doxygen comments.Adrian Prantl2018-05-091-1/+1
| | | | | | | | | | | | | | | | | | | This is similar to the LLVM change https://reviews.llvm.org/D46290. We've been running doxygen with the autobrief option for a couple of years now. This makes the \brief markers into our comments redundant. Since they are a visual distraction and we don't want to encourage more \brief markers in new code either, this patch removes them all. Patch produced by for i in $(git grep -l '\@brief'); do perl -pi -e 's/\@brief //g' $i & done for i in $(git grep -l '\\brief'); do perl -pi -e 's/\\brief //g' $i & done Differential Revision: https://reviews.llvm.org/D46320 llvm-svn: 331834
* Fix evaluation of `__has_include_next` during -frewrite-includes.Volodymyr Sapsai2018-04-131-14/+18
| | | | | | | | | | | | | | | | | | | | | | | `__has_include_next` requires correct DirectoryLookup for being evaluated correctly. We were using Preprocessor::GetCurDirLookup() but we were calling it after the preprocessor finished its work. And in this case CurDirLookup is always nullptr which makes `__has_include_next` behave as `__has_include`. Fix by storing and using CurDirLookup when preprocessor enters a file, not when we rewrite the includes. rdar://problem/36305026 Reviewers: bkramer Reviewed By: bkramer Subscribers: jkorous-apple, cfe-commits Differential Revision: https://reviews.llvm.org/D45603 llvm-svn: 330041
* Fix typos in clangAlexander Kornienko2018-04-061-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Found via codespell -q 3 -I ../clang-whitelist.txt Where whitelist consists of: archtype cas classs checkk compres definit frome iff inteval ith lod methode nd optin ot pres statics te thru Patch by luzpaz! (This is a subset of D44188 that applies cleanly with a few files that have dubious fixes reverted.) Differential revision: https://reviews.llvm.org/D44188 llvm-svn: 329399
* [Edit, Rewrite] Fix some Clang-tidy modernize and Include What You Use ↵Eugene Zelenko2018-03-271-12/+17
| | | | | | warnings; other minor fixes (NFC). llvm-svn: 328597
* Remove redundant casts. NFCGeorge Burgess IV2018-03-012-2/+2
| | | | | | | | | | | | | | | | | | | So I wrote a clang-tidy check to lint out redundant `isa`, `cast`, and `dyn_cast`s for fun. This is a portion of what it found for clang; I plan to do similar cleanups in LLVM and other subprojects when I find time. Because of the volume of changes, I explicitly avoided making any change that wasn't highly local and obviously correct to me (e.g. we still have a number of foo(cast<Bar>(baz)) that I didn't touch, since overloading is a thing and the cast<Bar> did actually change the type -- just up the class hierarchy). I also tried to leave the types we were cast<>ing to somewhere nearby, in cases where it wasn't locally obvious what we were dealing with before. llvm-svn: 326416
* Clean up use of C allocation functionsSerge Pavlov2018-02-211-4/+3
| | | | | | | | | | | | | | | | If the value returned by `malloc`, `calloc` or `realloc` is not checked for null pointer, this change replaces them for `safe_malloc`, `safe_calloc` or `safe_realloc`, which are defined in the namespace `llvm`. These function report fatal error on out of memory. In the plain C files, assertion statements are added to ensure that memory is successfully allocated. The aim of this change is to get better diagnostics of OOM on Windows. Differential Revision: https://reviews.llvm.org/D43017 llvm-svn: 325661
* Track in the AST whether the operand to a UnaryOperator can overflow and ↵Aaron Ballman2018-01-092-24/+29
| | | | | | then use that logic when evaluating constant expressions and emitting codegen. llvm-svn: 322074
* [CMake] Use #cmakedefine01 for ↵NAKAMURA Takumi2017-10-183-3/+3
| | | | | | | | | | | | CLANG_ENABLE_(ARCMT|OBJC_REWRITER|STATIC_ANALYZER) It'd be better that they are #cmakedefine01 rather than #cmakedefine. (#if FOO rather than #if defined(FOO)) Then we can find missing #include "clang/Config/config.h" in the future. Differential Revision: https://reviews.llvm.org/D35541 llvm-svn: 316061
* [CMake] Move CLANG_ENABLE_(ARCMT|OBJC_REWRITER|STATIC_ANALYZER) into ↵NAKAMURA Takumi2017-07-183-0/+3
| | | | | | | | | | | | | | clang/Config/config.h. LLVM_ENABLE_MODULES is sensitive of -D. Move them into config.h. FIXME: It'd be better that they are #cmakedefine01 rather than #cmakedefine. (#if FOO rather than #if defined(FOO)) Then we can find missing #include "clang/Config/config.h" in the future. Differential Revision: https://reviews.llvm.org/D35527 llvm-svn: 308277
* [Objective-C] Fix non-determinism in clangMandeep Singh Grang2017-07-061-4/+5
| | | | | | | | | | | | | | Summary: Iteration of the unordered Ivars causes objc-modern-metadata-visibility.mm (uncovered by reverse iterating SmallPtrSet). Reviewers: dblaikie, davide, rsmith Reviewed By: dblaikie Subscribers: cfe-commits, llvm-commits Differential Revision: https://reviews.llvm.org/D34860 llvm-svn: 307296
* fix trivial typos in comments; NFCHiroshi Inoue2017-07-032-2/+2
| | | | llvm-svn: 307007
* When preprocessing with -frewrite-imports and -fmodule-file=, do not pass allRichard Smith2017-06-261-0/+2
| | | | | | | | | | | modules to preprocessing of nested .pcm files. Making those module files available results in loading more .pcm files than necessary, and potentially in misbehavior if a module makes itself visible during its own compilation (as parts of that module that have not yet been processed would then become visible). llvm-svn: 306320
* Turn off "disable free" mode when preprocessing imported module files inRichard Smith2017-06-201-0/+1
| | | | | | | | | -frewrite-imports mode. This could end up accumulating a very large amount of intermediate state. Clear it out after each module file is processed. llvm-svn: 305764
* Support non-identifier module names when preprocessing modules.Richard Smith2017-06-192-6/+15
| | | | llvm-svn: 305758
* Attempt to fix shared library build: RewriteFrontend depends on ↵Richard Smith2017-06-091-0/+1
| | | | | | Serialization after r305116. llvm-svn: 305121
* Add -frewrite-imports flag.Richard Smith2017-06-091-14/+104
| | | | | | | | If specified, when preprocessing, the contents of imported .pcm files will be included in preprocessed output. The resulting preprocessed file can then be compiled standalone without the module sources or .pcm files. llvm-svn: 305116
* Remove 'Filename' parameter from BeginSourceFileAction.Richard Smith2017-06-091-2/+1
| | | | | | | | | No-one was using this, and it's not meaningful in general -- FrontendActions can be run on inputs that don't have a corresponding source file. The current frontend input can be obtained by asking the FrontendAction if any future action actually needs it. llvm-svn: 305045
* PR32848: There isn't necessarily a FileChanged or FileSkipped for every ↵Richard Smith2017-06-021-4/+3
| | | | | | | | | InclusionDirective callback. In particular, you don't get one if the inclusion directive encountered an error. Don't assert in that case. llvm-svn: 304506
* Escape filenames in module map line marker directives, to unbreak Windows ↵Richard Smith2017-06-011-2/+5
| | | | | | build bots. llvm-svn: 304464
* Add support for building modules from preprocessed source.Richard Smith2017-05-051-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | To support this, an optional marker "#pragma clang module contents" is recognized in module map files, and the rest of the module map file from that point onwards is treated as the source of the module. Preprocessing a module map produces the input module followed by the marker and then the preprocessed contents of the module. Ignoring line markers, a preprocessed module might look like this: module A { header "a.h" } #pragma clang module contents #pragma clang module begin A // ... a.h ... #pragma clang module end The preprocessed output generates line markers, which are not accepted by the module map parser, so -x c++-module-map-cpp-output should be used to compile such outputs. A couple of major parts do not work yet: 1) The files that are listed in the module map must exist on disk, in order to build the on-disk header -> module lookup table in the PCM file. To fix this, we need the preprocessed output to track the file size and other stat information we might use to build the lookup table. 2) Declaration ownership semantics don't work properly yet, since mapping from a source location to a module relies on mapping from FileIDs to modules, which we can't do if module transitions can occur in the middle of a file. llvm-svn: 302309
* Add #pragma clang module begin/end pragmas and generate them when ↵Richard Smith2017-05-041-0/+30
| | | | | | | | | | | | | | 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
* PR26771: don't forget the " 2" (returning from #included file) linemarker ↵Richard Smith2017-04-291-14/+9
| | | | | | after including an empty file with -frewrite-includes. llvm-svn: 301727
* Add pragma to perform module import and use it in -E output.Richard Smith2017-04-291-4/+2
| | | | | | | | | | | | | | | | | | | | | 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
* Preprocessor: Suppress -Wnonportable-include-path for header mapsDuncan P. N. Exon Smith2017-04-271-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If a file search involves a header map, suppress -Wnonportable-include-path. It's firing lots of false positives for framework authors internally, and it's not trivial to fix. Consider a framework called "Foo" with a main (installed) framework header "Foo/Foo.h". It's atypical for "Foo.h" to actually live inside a directory called "Foo" in the source repository. Instead, the build system generates a header map while building the framework. If Foo.h lives at the top-level of the source repository (common), and the git repo is called ssh://some.url/foo.git, then the header map will have something like: Foo/Foo.h -> /Users/myname/code/foo/Foo.h where "/Users/myname/code/foo" is the clone of ssh://some.url/foo.git. After #import <Foo/Foo.h>, the current implementation of -Wnonportable-include-path will falsely assume that Foo.h was found in a nonportable way, because of the name of the git clone (.../foo/Foo.h). However, that directory name was not involved in the header search at all. This commit adds an extra parameter to Preprocessor::LookupFile and HeaderSearch::LookupFile to track if the search used a header map, making it easy to suppress the warning. Longer term, once we find a way to avoid the false positive, we should turn the warning back on. rdar://problem/28863903 llvm-svn: 301592
* Spelling mistakes in comments. NFCI. (PR27635)Simon Pilgrim2017-03-303-3/+3
| | | | llvm-svn: 299083
* Encapsulate FPOptions and use it consistentlyAdam Nemet2017-03-272-2/+2
| | | | | | | | | | | | | | | | | | Sema holds the current FPOptions which is adjusted by 'pragma STDC FP_CONTRACT'. This then gets propagated into expression nodes as they are built. This encapsulates FPOptions so that this propagation happens opaquely rather than directly with the fp_contractable on/off bit. This allows controlled transitioning of fp_contractable to a ternary value (off, on, fast). It will also allow adding more fast-math flags later. This is toward moving fp-contraction=fast from an LLVM TargetOption to a FastMathFlag in order to fix PR25721. Differential Revision: https://reviews.llvm.org/D31166 llvm-svn: 298877
* Pass a char instead of a string to the find function. clang-tidy: ↵Sylvestre Ledru2017-01-282-2/+2
| | | | | | performance-faster-string-find llvm-svn: 293379
* getObjCEncodingForMethodDecl cannot fail. Simplify. NFC.John McCall2016-11-292-14/+13
| | | | llvm-svn: 288203
* Fix Clang-tidy readability-redundant-string-cstr warningsMalcolm Parsons2016-11-022-24/+18
| | | | | | | | | | Reviewers: aaron.ballman, mehdi_amini, dblaikie Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D26206 llvm-svn: 285799
* Use StringRef for MemoryBuffer identifier API (NFC)Mehdi Amini2016-10-012-4/+4
| | | | llvm-svn: 283043
* [NFC] Header cleanupMehdi Amini2016-07-183-6/+4
| | | | | | | | | | Summary: Removed unused headers, replaced some headers with forward class declarations Patch by: Eugene <claprix@yandex.ru> Differential Revision: https://reviews.llvm.org/D20100 llvm-svn: 275882
* Frontend: Simplify ownership model for clang's output streams.Peter Collingbourne2016-07-154-47/+54
| | | | | | | | | | | | | | This changes the CompilerInstance::createOutputFile function to return a std::unique_ptr<llvm::raw_ostream>, rather than an llvm::raw_ostream implicitly owned by the CompilerInstance. This in most cases required that I move ownership of the output stream to the relevant ASTConsumer. The motivation for this change is to allow BackendConsumer to be a client of interfaces such as D20268 which take ownership of the output stream. Differential Revision: http://reviews.llvm.org/D21537 llvm-svn: 275507
* Use more ArrayRefsDavid Majnemer2016-06-242-6/+6
| | | | | | No functional change is intended, just a small refactoring. llvm-svn: 273647
* Delete dead code.Rafael Espindola2016-06-211-96/+0
| | | | | | Found by gcc 6. llvm-svn: 273327
* Apply clang-tidy's misc-move-constructor-init throughout Clang.Benjamin Kramer2016-05-271-2/+3
| | | | | | No functionality change intended, maybe a tiny performance improvement. llvm-svn: 270996
* Fix a couple assertions that can never fire because the condition ANDed with ↵Craig Topper2016-04-242-2/+2
| | | | | | the string is just true or 1. llvm-svn: 267313
* [modules] Don't write @import in -E output if the current language mode doesn'tRichard Smith2016-04-081-1/+3
| | | | | | support @import; use the form as written instead. llvm-svn: 265756
* [Objective-c] Stop attaching section "datacoal_nt" to global variables.Akira Hatanaka2016-02-111-1/+1
| | | | | | | | | | | | | The current macho linker just copies symbols in section datacoal_nt to section data, so it doesn't really matter whether or not section "datacoal_nt" is attached to the global variable. This is a follow-up to r250370, which made changes in llvm to stop putting functions and data in the *coal* sections. rdar://problem/24528611 llvm-svn: 260496
* Fix some Clang-tidy readability-redundant-control-flow warnings; other minor ↵Eugene Zelenko2016-02-102-88/+35
| | | | | | | | fixes. Differential revision: http://reviews.llvm.org/D17060 llvm-svn: 260414
* Move DebugInfoKind into its own header to cut the cyclic dependency edge ↵Benjamin Kramer2016-02-021-5/+4
| | | | | | from Driver to Frontend. llvm-svn: 259489
* Remove autoconf supportChris Bieneman2016-01-261-22/+0
| | | | | | | | | | | | | | | | | Summary: This patch is provided in preparation for removing autoconf on 1/26. The proposal to remove autoconf on 1/26 was discussed on the llvm-dev thread here: http://lists.llvm.org/pipermail/llvm-dev/2016-January/093875.html "This is the way [autoconf] ends Not with a bang but a whimper." -T.S. Eliot Reviewers: chandlerc, grosbach, bob.wilson, echristo Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D16472 llvm-svn: 258862
* Use instance_properties instead of properties. NFC.Manman Ren2016-01-262-9/+12
| | | | | | | | | | | All current properties are instance properties. This is the second patch in a series of patches to support class properties in addition to instance properties in objective-c. rdar://23891898 llvm-svn: 258824
* Fix a couple places where InsertText was being called with a pointer and ↵Craig Topper2015-10-222-5/+5
| | | | | | | | size when it really expects a StringRef and a normally optional bool argument. The pointer was being implicitly converted to a StringRef and the size was being passed into the bool. Since the bool has a default value normally, no one noticed that the wrong number of arguments was given. llvm-svn: 250977
* Pass an ArrayRef instead of pointer and size. NFCCraig Topper2015-10-222-68/+38
| | | | llvm-svn: 250976
OpenPOWER on IntegriCloud