summaryrefslogtreecommitdiffstats
path: root/include/clang/Basic/SourceManager.h
Commit message (Collapse)AuthorAgeFilesLines
* Allow force updating the NumCreatedFIDsForFileID.Vassil Vassilev2018-11-201-2/+3
| | | | | | | | | | | Our internal clients implement parsing cache based on FileID. In order for the Preprocessor to reenter the cached FileID it needs to reset its NumCreatedFIDsForFileID. Differential Revision: https://reviews.llvm.org/D51295 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@347304 91177308-0d34-0410-b5e6-96231b3b80d8
* [clang] Move two utility functions into SourceManagerRoman Lebedev2018-10-301-0/+12
| | | | | | | | | | | | | | | | Summary: So we can keep that not-so-great logic in one place. Reviewers: rsmith, aaron.ballman Reviewed By: rsmith Subscribers: nemanjai, kbarton, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D53837 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@345594 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix the type of 1<<31 integer constants.Benjamin Kramer2018-09-241-2/+2
| | | | | | | Shifting into the sign bit is technically undefined behavior. No known compiler exploits it though. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@342909 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove trailing spaceFangrui Song2018-07-301-4/+4
| | | | | | sed -Ei 's/[[:space:]]+$//' include/**/*.{def,h,td} lib/**/*.{cpp,h} git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338291 91177308-0d34-0410-b5e6-96231b3b80d8
* Replace LLVM_ALIGNAS with just alignas.Richard Smith2018-07-171-1/+1
| | | | | | | Various places in Clang and LLVM are already using alignas; it seems our minimum host configuration now requires it. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@337330 91177308-0d34-0410-b5e6-96231b3b80d8
* Add SourceManagerForFile helper which sets up SourceManager and dependencies ↵Eric Liu2018-05-091-1/+23
| | | | | | | | | | | | | | | | for a single file with code snippet Summary: This can be used to create a virtual environment (incl. VFS, source manager) for code snippets. Reviewers: sammccall, klimek Reviewed By: sammccall Subscribers: klimek, mgorny, cfe-commits Differential Revision: https://reviews.llvm.org/D46176 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@331923 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove \brief commands from doxygen comments.Adrian Prantl2018-05-091-176/+176
| | | | | | | | | | | | | | | | | | | 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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@331834 91177308-0d34-0410-b5e6-96231b3b80d8
* PR37189 Fix incorrect end source location and spelling for a split '>>' token.Richard Smith2018-04-301-13/+52
| | | | | | | | | | | | | | | | | | | When a '>>' token is split into two '>' tokens (in C++11 onwards), or (as an extension) when we do the same for other tokens starting with a '>', we can't just use a location pointing to the first '>' as the location of the split token, because that would result in our miscomputing the length and spelling for the token. As a consequence, for example, a refactoring replacing 'A<X>' with something else would sometimes replace one character too many, and similarly diagnostics highlighting a template-id source range would highlight one character too many. Fix this by creating an expansion range covering the first character of the '>>' token, whose spelling is '>'. For this to work, we generalize the expansion range of a macro FileID to be either a token range (the common case) or a character range (used in this new case). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@331155 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix typo.Richard Smith2018-04-271-2/+2
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@331017 91177308-0d34-0410-b5e6-96231b3b80d8
* [NFC] Extract method to SourceManager for traversing the macro "stack"George Karpenkov2018-02-091-0/+3
| | | | | | | | | | | | The code for going up the macro arg expansion is duplicated in many places (and we need it for the analyzer as well, so I did not want to duplicate it two more times). This patch is an NFC, so the semantics should remain the same. Differential Revision: https://reviews.llvm.org/D42458 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@324780 91177308-0d34-0410-b5e6-96231b3b80d8
* [modules] Fix incorrect diagnostic mapping computation when a module changesRichard Smith2018-02-091-0/+12
| | | | | | | | | | | | | | | | diagnostic settings using _Pragma within a macro. The AST writer had previously been assuming that all diagnostic state transitions would occur within a FileID corresponding to a file. When a diagnostic state change occured within a macro, it was unable to form a location for that state change and would instead corrupt the diagnostic state of the "root" node (and thus that of the main compilation). Also introduce a "#pragma clang __debug diag_mapping" debugging utility that I added to track this issue down. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@324695 91177308-0d34-0410-b5e6-96231b3b80d8
* [Basic] Fix some Clang-tidy modernize and Include What You Use warnings; ↵Eugene Zelenko2017-11-031-37/+35
| | | | | | other minor fixes (NFC). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@317381 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix ownership of the MemoryBuffer in a FrontendInputFile.Richard Smith2017-09-091-8/+17
| | | | | | | | | This fixes a possible crash on certain kinds of corrupted AST file, but checking in an AST file corrupted in just the right way will be a maintenance nightmare because the format changes frequently. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@312851 91177308-0d34-0410-b5e6-96231b3b80d8
* [refactor] Add the AST source selection componentAlex Lorenz2017-08-241-0/+8
| | | | | | | | | | | | | | This commit adds the base AST source selection component to the refactoring library. AST selection is represented using a tree of SelectedASTNode values. Each selected node gets its own selection kind, which can actually be None even in the middle of tree (e.g. statement in a macro whose child is in a macro argument). The initial version constructs a "raw" selection tree, without applying filters and canonicalisation operations to the nodes. Differential Revision: https://reviews.llvm.org/D35012 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@311655 91177308-0d34-0410-b5e6-96231b3b80d8
* Factor out a functionality from isBeforeInTranslationUnitGabor Horvath2017-06-291-0/+11
| | | | | | | | | | | The first user of this API will be the cross translation unit functionality of the Static Analyzer which will be committed in a follow-up patch. Differential Revision: https://reviews.llvm.org/D34506 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@306648 91177308-0d34-0410-b5e6-96231b3b80d8
* Track the set of module maps read while building a .pcm file and reload ↵Richard Smith2017-06-291-19/+31
| | | | | | those when preprocessing from that .pcm file. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@306628 91177308-0d34-0410-b5e6-96231b3b80d8
* Rather than rejecting attempts to run preprocessor-only actions on AST files,Richard Smith2017-06-051-0/+4
| | | | | | | | | | | replay the steps taken to create the AST file with the preprocessor-only action installed to produce preprocessed output. This can be used to produce the preprocessed text for an existing .pch or .pcm file. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@304726 91177308-0d34-0410-b5e6-96231b3b80d8
* Give files from #line the characteristics of the current fileReid Kleckner2017-05-221-2/+1
| | | | | | | | | | This allows #line directives to appear in system headers that have code that clang would normally warn on. This is compatible with GCC, which is easy to test by running `gcc -E`. Fixes PR30752 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@303582 91177308-0d34-0410-b5e6-96231b3b80d8
* Constify.Vassil Vassilev2017-05-171-1/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@303250 91177308-0d34-0410-b5e6-96231b3b80d8
* [AST, ASTMatchers, Basic] Fix some Clang-tidy modernize and Include What You ↵Eugene Zelenko2016-12-091-22/+29
| | | | | | Use warnings; other minor fixes (NFC). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@289160 91177308-0d34-0410-b5e6-96231b3b80d8
* Retire llvm::alignOf in favor of C++11 alignof.Benjamin Kramer2016-10-201-2/+1
| | | | | | No functionality change intended. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@284730 91177308-0d34-0410-b5e6-96231b3b80d8
* [Basic] unique_ptr-ify SourceManager::MacroArgsCacheMap (NFC)Vedant Kumar2016-10-181-2/+3
| | | | | | Differential Revision: https://reviews.llvm.org/D25711 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@284442 91177308-0d34-0410-b5e6-96231b3b80d8
* Use StringRef for MemoryBuffer identifier API (NFC)Mehdi Amini2016-10-011-1/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@283043 91177308-0d34-0410-b5e6-96231b3b80d8
* [Basic] Add const qualifier to SM.isInSystemMacro (NFC)Vedant Kumar2016-08-121-1/+1
| | | | | | | | | | | The member function is a predicate, and doesn't apply any changes on the object. Patch by Visoiu Mistrih Francis! Differential Revision: https://reviews.llvm.org/D23433 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@278444 91177308-0d34-0410-b5e6-96231b3b80d8
* [NFC] Header cleanupMehdi Amini2016-07-181-1/+0
| | | | | | | | | | Summary: Removed unused headers, replaced some headers with forward class declarations Patch by: Eugene <claprix@yandex.ru> Differential Revision: https://reviews.llvm.org/D20100 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@275882 91177308-0d34-0410-b5e6-96231b3b80d8
* Added formatAndApplyAllReplacements that works on multiple files in libTooling.Eric Liu2016-03-291-0/+9
| | | | | | | | | | | | | | Summary: formatAndApplyAllReplacements takes a set of Replacements, applies them on a Rewriter, and reformats the changed code. Reviewers: klimek, djasper Subscribers: ioeric, klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D17852 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@264745 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove unnecessary forward declaration. NFCCraig Topper2016-01-291-1/+0
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@259156 91177308-0d34-0410-b5e6-96231b3b80d8
* [modules] Refactor handling of -fmodules-embed-*. Track this properly ratherRichard Smith2015-11-261-14/+15
| | | | | | | | than reusing the "overridden buffer" mechanism. This will allow us to make embedded files and overridden files behave differently in future. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@254121 91177308-0d34-0410-b5e6-96231b3b80d8
* [modules] Add -cc1 flag -fmodules-embed-all-files.Richard Smith2015-11-241-0/+11
| | | | | | | | | | | | | | | This flag causes all files that were read by the compilation to be embedded into a produced module file. This is useful for distributed build systems that use an include scanning system to determine which files are "needed" by a compilation, and only provide those files to remote compilation workers. Since using a module can require any file that is part of that module (or anything it transitively includes), files that are not found by an include scanner can be required in a regular build using explicit modules. With this flag, only files that are actually referenced by transitively-#included files are required to be present on the build machine. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@253950 91177308-0d34-0410-b5e6-96231b3b80d8
* [Basic] Replace vector<bool> with BitVector in SourceManager. NFC.Vedant Kumar2015-11-161-1/+2
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@253181 91177308-0d34-0410-b5e6-96231b3b80d8
* [Basic] Use a bitfield in SLocEntry for clarity. NFC.Vedant Kumar2015-11-161-5/+10
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@253177 91177308-0d34-0410-b5e6-96231b3b80d8
* Improve the printing of ranges when macros are involved.Richard Trieu2015-09-241-1/+5
| | | | | | | | | | | | | Trace the ranges through the macro backtrace better. This allows better range highlighting through all levels of the macro bracktrace. Also some improvements to backtrace printer for omitting different backtraces. Patch by Zhengkai Wu. Differential Revision: http://reviews.llvm.org/D12379 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@248454 91177308-0d34-0410-b5e6-96231b3b80d8
* [modules] Add an experimental -cc1 feature to embed the contents of an inputRichard Smith2015-08-141-0/+7
| | | | | | | | | | | | file in the .pcm files. This allows a smaller set of files to be sent to a remote build worker when building with explicit modules (for instance, module map files need not be sent along with the corresponding precompiled modules). This doesn't actually make the embedded files visible to header search, so it's not useful as a packaging format for public header files. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@245028 91177308-0d34-0410-b5e6-96231b3b80d8
* Add SourceManager::dump() to dump the current set of SLocEntries.Richard Smith2015-08-131-0/+2
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@244852 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert r240270 ("Fixed/added namespace ending comments using clang-tidy").Alexander Kornienko2015-06-221-1/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@240353 91177308-0d34-0410-b5e6-96231b3b80d8
* Fixed/added namespace ending comments using clang-tidy. NFCAlexander Kornienko2015-06-221-1/+1
| | | | | | | | | | | | | | The patch is generated using this command: $ tools/extra/clang-tidy/tool/run-clang-tidy.py -fix \ -checks=-*,llvm-namespace-comment -header-filter='llvm/.*|clang/.*' \ work/llvm/tools/clang To reduce churn, not touching namespaces spanning less than 10 lines. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@240270 91177308-0d34-0410-b5e6-96231b3b80d8
* Replace custom alignment enforcement with LLVM_ALIGNAS.Benjamin Kramer2015-04-021-18/+4
| | | | | | | | | | This isn't perfect as it still assumes sizeof(void*) == alignof(void*), but we can fix that when compiler support gets better. Shrinks some Stmts that happen to inherit from Stmt and have a SourceLocation as the first member (64 bit archs only). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@233911 91177308-0d34-0410-b5e6-96231b3b80d8
* Removing LLVM_DELETED_FUNCTION, as MSVC 2012 was the last reason for ↵Aaron Ballman2015-02-151-3/+3
| | | | | | requiring the macro. NFC; Clang edition. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@229339 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix layering violation: include/clang/Basic/PlistSupport.h should not includeRichard Smith2015-01-281-1/+7
| | | | | | | files from include/clang/Lex. Clean up module map. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@227361 91177308-0d34-0410-b5e6-96231b3b80d8
* Constify a functor's function call operator because it can/should be.David Blaikie2014-09-241-1/+1
| | | | | | Patch by Graham Lee (graham@iamleeg.com)! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@218385 91177308-0d34-0410-b5e6-96231b3b80d8
* unique_ptrify SourceManager::createFileIDDavid Blaikie2014-08-291-7/+7
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@216715 91177308-0d34-0410-b5e6-96231b3b80d8
* Overload SourceManager::overrideFileContents so that unconditionally passing ↵David Blaikie2014-08-271-1/+5
| | | | | | | | | | ownership is explicitly done using unique_ptr. Only those callers who are dynamically passing ownership should need the 3 argument form. Those accepting the default ("do pass ownership") should do so explicitly with a unique_ptr now. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@216614 91177308-0d34-0410-b5e6-96231b3b80d8
* Add support for the static analyzer to synthesize function implementations ↵Ted Kremenek2014-08-271-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | from external model files. Currently the analyzer lazily models some functions using 'BodyFarm', which constructs a fake function implementation that the analyzer can simulate that approximates the semantics of the function when it is called. BodyFarm does this by constructing the AST for such definitions on-the-fly. One strength of BodyFarm is that all symbols and types referenced by synthesized function bodies are contextual adapted to the containing translation unit. The downside is that these ASTs are hardcoded in Clang's own source code. A more scalable model is to allow these models to be defined as source code in separate "model" files and have the analyzer use those definitions lazily when a function body is needed. Among other things, it will allow more customization of the analyzer for specific APIs and platforms. This patch provides the initial infrastructure for this feature. It extends BodyFarm to use an abstract API 'CodeInjector' that can be used to synthesize function bodies. That 'CodeInjector' is implemented using a new 'ModelInjector' in libFrontend, which lazily parses a model file and injects the ASTs into the current translation unit. Models are currently found by specifying a 'model-path' as an analyzer option; if no path is specified the CodeInjector is not used, thus defaulting to the current behavior in the analyzer. Models currently contain a single function definition, and can be found by finding the file <function name>.model. This is an initial starting point for something more rich, but it bootstraps this feature for future evolution. This patch was contributed by Gábor Horváth as part of his Google Summer of Code project. Some notes: - This introduces the notion of a "model file" into FrontendAction and the Preprocessor. This nomenclature is specific to the static analyzer, but possibly could be generalized. Essentially these are sources pulled in exogenously from the principal translation. Preprocessor gets a 'InitializeForModelFile' and 'FinalizeForModelFile' which could possibly be hoisted out of Preprocessor if Preprocessor exposed a new API to change the PragmaHandlers and some other internal pieces. This can be revisited. FrontendAction gets a 'isModelParsingAction()' predicate function used to allow a new FrontendAction to recycle the Preprocessor and ASTContext. This name could probably be made something more general (i.e., not tied to 'model files') at the expense of losing the intent of why it exists. This can be revisited. - This is a moderate sized patch; it has gone through some amount of offline code review. Most of the changes to the non-analyzer parts are fairly small, and would make little sense without the analyzer changes. - Most of the analyzer changes are plumbing, with the interesting behavior being introduced by ModelInjector.cpp and ModelConsumer.cpp. - The new functionality introduced by this change is off-by-default. It requires an analyzer config option to enable. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@216550 91177308-0d34-0410-b5e6-96231b3b80d8
* Use std::unique_ptr to simplify this code a bit.Rafael Espindola2014-08-181-2/+2
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@215926 91177308-0d34-0410-b5e6-96231b3b80d8
* Header guard canonicalization, clang part.Benjamin Kramer2014-08-131-2/+2
| | | | | | Modifications made by clang-tidy with minor tweaks. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@215557 91177308-0d34-0410-b5e6-96231b3b80d8
* Trivial doc fixes: add missing whitespace, and s/overriden/overridden/g.James Dennett2014-07-211-5/+6
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@213502 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove 'const' from MemoryBuffers used through the SourceManagerDavid Blaikie2014-06-271-22/+18
| | | | | | | | | | | | | | This removes a const_cast added in r211884 that occurred due to an inconsistency in how MemoryBuffers are handled between some parts of clang and LLVM. MemoryBuffers are immutable and the general convention in the LLVM project is to omit const from immutable types as it's simply redundant/verbose (see llvm::Type, for example). While this change doesn't remove "const" from /every/ MemoryBuffer, it at least makes this chain of ownership/usage consistent. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@211915 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix typosAlp Toker2014-06-161-1/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@211025 91177308-0d34-0410-b5e6-96231b3b80d8
* SourceManager: Use setMainFileID() consistentlyAlp Toker2014-05-211-20/+0
| | | | | | | | | | | Eliminate createMainFileID() / createMainFileIDForMemBuffer() utility functions. These didn't add much convenience and conflated two distinct operations. This change makes things easier to follow by providing a consistent interface and getting rid of a bunch of cast-to-voids. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@209266 91177308-0d34-0410-b5e6-96231b3b80d8
* Rename SourceManager::createFileIDForMemBuffer()Alp Toker2014-05-161-4/+4
| | | | | | | | It makes more sense to just overload createFileID(). Gardening only. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@209002 91177308-0d34-0410-b5e6-96231b3b80d8