summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CoverageMappingGen.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Fix use-of-temporary with StringRef in code coverageJordan Rose2016-11-071-2/+7
| | | | | | | | | | | | | The fixed code is basically identical to the same loop below, which might indicate an opportunity for refactoring. I just wanted to fix the use-of-temporary issue. Caught by adding a similar check to StringRef as r283798 did for ArrayRef. I'll be upstreaming that soon. Reviewed by Vedant Kumar as https://reviews.llvm.org/D26317. llvm-svn: 286122
* [Coverage] Support for C++17 if initializersVedant Kumar2016-10-141-0/+3
| | | | | | Differential Revision: https://reviews.llvm.org/D25572 llvm-svn: 284293
* [Coverage] Support for C++17 switch initializersVedant Kumar2016-10-141-0/+2
| | | | | | Differential Revision: https://reviews.llvm.org/D25539 llvm-svn: 284292
* Use StringRef for MemoryBuffer identifier API (NFC)Mehdi Amini2016-10-011-1/+1
| | | | llvm-svn: 283043
* [Coverage] The coverage region for switch covers the code after the switch.Alex Lorenz2016-09-271-1/+5
| | | | | | | | | | | | | | This patch fixes a regression introduced in r262697 that changed the way the coverage regions for switches are constructed. The PGO instrumentation counter for a switch statement refers to the counter at the exit of the switch. Therefore, the coverage region for the switch statement should cover the code that comes after the switch, and not the switch statement itself. rdar://28480997 Differential Revision: https://reviews.llvm.org/D24981 llvm-svn: 282554
* [Coverage] Suppress creating a code region if the same area is covered by an ↵Igor Kudrin2016-08-311-5/+23
| | | | | | | | | | | | expansion region. In most cases these code regions are just redundant, but sometimes they could be assigned to the counter of the parent code region instead of the counter of the nested block. Differential Revision: https://reviews.llvm.org/D23987 llvm-svn: 280199
* [Coverage] Prevent creating a redundant counter if a nested body ends with a ↵Igor Kudrin2016-08-291-1/+2
| | | | | | | | | | | | | | | | | macro. If there were several nested statements arranged in a way that all of them end up with the same macro, then the expansion of this macro was assigned with all the corresponding counters of these statements. As a result, the wrong counter value was shown for the macro in llvm-cov. This patch fixes the issue by preventing adding a counter for an expanded source range if it already has an assigned counter, which is expected to come from the most specific statement. Differential Revision: https://reviews.llvm.org/D23160 llvm-svn: 279962
* [Coverage] Do not write out coverage mappings with zero entriesVedant Kumar2016-07-261-0/+11
| | | | | | | | | | | | | After r275121, we stopped mapping regions from system headers. Lambdas declared in regions belonging to system headers started producing empty coverage mappings, since the files corresponding to their spelling locs were being ignored. The coverage reader doesn't know what to do with these empty mappings. This commit makes sure that we don't produce them and adds a test. I'll make the reader stricter in a follow-up commit. llvm-svn: 276716
* [Coverage] Remove '..' from filenames *after* getting an absolute pathVedant Kumar2016-07-181-1/+1
| | | | | | | | Failure to do this breaks relative paths which begin with '..'. This issue was caught by the (still nascent) coverage bot. llvm-svn: 275924
* [Coverage] Normalize '..' out of filename stringsVedant Kumar2016-07-181-8/+14
| | | | | | | | This fixes the issue of having duplicate entries for the same file in a coverage report s.t none of the entries actually displayed the correct coverage information. llvm-svn: 275913
* [Coverage] Do not map regions from system headersVedant Kumar2016-07-111-0/+8
| | | | | | | | | | | | | | | Do not assign source regions located within system headers file ID's, and do not construct counter mapping regions out of them. This makes coverage reports less cluttered and less mysterious. E.g using the "assert" macro doesn't cause assert.h to appear in reports, and it no longer shows the "assertion failed" branch as an uncovered region. It also makes coverage mapping sections a bit smaller (e.g a 1% reduction in a stage2 build of bin/llvm-as). llvm-svn: 275121
* Delete some dead code, NFCVedant Kumar2016-07-061-10/+0
| | | | | | Found using clang's code coverage tool. llvm-svn: 274599
* Revert "[Coverage] Adopt llvm::coverage::encodeFilenamesAndRawMappings (NFC)"Vedant Kumar2016-06-291-10/+18
| | | | | | | | | This reverts commit 161ff9db3a3d0d62880d1cb18d58182cd3034912 (r273056). This is breaking stage2 instrumented builds with "malformed coverage data" errors. llvm-svn: 274104
* [Coverage] Push a new region when handling CXXTryStmtsVedant Kumar2016-06-221-1/+6
| | | | | | | | Push a new region for the try block and propagate execution counts through it. This ensures that catch statements get a region counter distinct from the try block's counter. llvm-svn: 273463
* [Coverage] Adopt llvm::coverage::encodeFilenamesAndRawMappings (NFC)Vedant Kumar2016-06-171-18/+10
| | | | | | Use an llvm helper function to encode filenames and raw mappings. llvm-svn: 273056
* Reapply [Coverage] Fix an assertion failure if the definition of an unused ↵Igor Kudrin2016-06-071-11/+31
| | | | | | | | | | | | | | | function spans multiple files. We have an assertion failure if, for example, the definition of an unused inline function starts in one macro and ends in another. This patch fixes the issue by finding the common ancestor of the start and end locations of that function's body and changing the locations accordingly. Thanks to NAKAMURA Takumi for helping with fixing the test failure on Windows. Differential Revision: http://reviews.llvm.org/D20997 llvm-svn: 271995
* Revert [Coverage] Fix an assertion failure if the definition of an unused ↵Igor Kudrin2016-06-071-31/+11
| | | | | | | | function spans multiple files. r271969 The test case fails on Windows. llvm-svn: 271976
* [Coverage] Fix an assertion failure if the definition of an unused function ↵Igor Kudrin2016-06-071-11/+31
| | | | | | | | | | | | | spans multiple files. We have an assertion failure if, for example, the definition of an unused inline function starts in one macro and ends in another. This patch fixes the issue by finding the common ancestor of the start and end locations of that function's body and changing the locations accordingly. Differential Revision: http://reviews.llvm.org/D20997 llvm-svn: 271969
* [Coverage] Remove redundant handleFileExit() call (NFC)Vedant Kumar2016-05-311-3/+1
| | | | | | | | | I added this call in r271308. It's redundant because it's dominated by a call to extendRegion(). Thanks to Justin Bogner for pointing this out! llvm-svn: 271331
* [Coverage] Fix crash on a switch partially covered by a macro (PR27948)Vedant Kumar2016-05-311-2/+6
| | | | | | | We have to handle file exits before and after visiting regions in the switch body. Fixes PR27948. llvm-svn: 271308
* [Coverage] Fix an issue where a coverage region might not be created for a ↵Igor Kudrin2016-05-041-3/+19
| | | | | | | | | | | macro containing a loop statement. The issue happened when a macro contained a full for or while statement, which body ended at the end of the macro. Differential Revision: http://reviews.llvm.org/D19725 llvm-svn: 268511
* Use the new path for coverage related headers and update CMakeLists.txtEaswaran Raman2016-04-291-3/+3
| | | | | | Differential Revision: http://reviews.llvm.org/D19612 llvm-svn: 268090
* [Coverage] Fix the start/end locations of switch statementsVedant Kumar2016-03-041-1/+1
| | | | | | | | | | | | While pushing switch statements onto the region stack we neglected to specify their start/end locations. This results in a crash (PR26825) if we end up in nested macro expansions without enough information to handle the relevant file exits. I added a test in switchmacro.c and fixed up a bunch of incorrect CHECK lines that specify strange end locations for switches. llvm-svn: 262697
* [Coverage] Fix crash when handling certain macro expansionsVedant Kumar2016-02-081-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | When handling 'if' statements, we crash if the condition and the consequent branch are spanned by a single macro expansion. The crash occurs because of a sanity 'reset' in popRegions(): if an expansion exactly spans an entire region, we set MostRecentLocation to the start of the expansion (its 'include location'). This ensures we don't handleFileExit() ourselves out of the expansion before we're done processing all of the regions within it. This is tested in test/CoverageMapping/macro-expressions.c. This causes a problem when an expansion spans both the condition and the consequent branch of an 'if' statement. MostRecentLocation is updated to the start of the 'if' statement in popRegions(), so the file for the expansion isn't exited by the time we're done handling the statement. We then crash with 'fatal: File exit not handled before popRegions'. The fix for this is to detect these kinds of expansions, and conservatively update MostRecentLocation to the end of expansion region containing the conditional. I've added tests to make sure we don't have the same problem with other kinds of statements. rdar://problem/23630316 Differential Revision: http://reviews.llvm.org/D16934 llvm-svn: 260129
* [Coverage] Use a set to track visited FileIDs (NFC)Vedant Kumar2016-01-281-3/+3
| | | | llvm-svn: 259061
* [Coverage] Reduce complexity of adding function mapping recordsVedant Kumar2016-01-211-3/+6
| | | | | | | | | | Replace a string append operation in addFunctionMappingRecord with a vector append. The existing behavior is quadratic in the worst case: this patch makes it linear. Differential Revision: http://reviews.llvm.org/D16395 llvm-svn: 258424
* Reference the updated function name /NFCXinliang David Li2016-01-201-1/+1
| | | | llvm-svn: 258261
* Fix local variable name /NFCXinliang David Li2016-01-191-2/+2
| | | | llvm-svn: 258106
* [PGO] Simplify coverage mapping loweringXinliang David Li2016-01-071-3/+17
| | | | | | | | | | | | | | | | Coverage mapping data may reference names of functions that are skipped by FE (e.g, unused inline functions). Since those functions are skipped, normal instr-prof function lowering pass won't put those names in the right section, so special handling is needed to walk through coverage mapping structure and recollect the references. With this patch, only names that are skipped are processed. This simplifies the lowering code and it no longer needs to make assumptions coverage mapping data layout. It should also be more efficient. llvm-svn: 257092
* [PGO] Cleanup: Use covmap header definition in the template fileXinliang David Li2016-01-031-14/+20
| | | | | | | | | | | | | | This is one last remaining instrumentatation related structure that needs to be migrate to use the centralized template definition. With this change, instrumentation code related to coverage module header will be kept in sync with the coverage mapping reader. The remaining code which makes implicit assumption about covmap control structure layout in the the lowering pass will cleaned up in a different patch. This patch is not intended to have no functional change. llvm-svn: 256714
* use auto for obvious type; NFCSanjay Patel2015-12-241-1/+1
| | | | llvm-svn: 256393
* Use profile data template file for covmap func record (NFC)Xinliang David Li2015-11-051-11/+10
| | | | llvm-svn: 252147
* Use newly introduced interfaces in LLVM (NFC)Xinliang David Li2015-10-221-2/+2
| | | | | | | Replaced references to raw strings in instrumentation and coverage code. llvm-svn: 251072
* Replace double negation of !FileID.isInvalid() with FileID.isValid().Yaron Keren2015-10-031-1/+1
| | | | | | +couple more of double-negated !SourceLocation.isInvalid() unfixed in r249228. llvm-svn: 249235
* Replace double-negated !SourceLocation.isInvalid() with ↵Yaron Keren2015-10-031-2/+2
| | | | | | SourceLocation.isValid(). llvm-svn: 249228
* Remove move constructor and assignment operator from SourceMappingRegion. ↵Craig Topper2015-09-261-12/+1
| | | | | | The types of the fields are trivially copyable. NFC llvm-svn: 248659
* Fix a couple other places that were returning SourceLocation by reference. NFCCraig Topper2015-09-261-2/+2
| | | | llvm-svn: 248658
* Use llvm::reverse to make a bunch of loops use foreach. NFC.Pete Cooper2015-07-301-6/+6
| | | | | | | | | | | | | | | | In llvm commit r243581, a reverse range adapter was added which allows us to change code such as for (auto I = Fields.rbegin(), E = Fields.rend(); I != E; ++I) { in to for (const FieldDecl *I : llvm::reverse(Fields)) This commit changes a few of the places in clang which are eligible to use this new adapter. llvm-svn: 243663
* InstrProf: Don't extend coverage regions into the catch keywordJustin Bogner2015-07-231-1/+0
| | | | | | | | The catch keyword isn't really part of a region, so it's fairly meaningless to extend into it. This was usually harmless, but it could crash when catch blocks involved macros in strange ways. llvm-svn: 243066
* InstrProf: Promote this assert to a report_fatal_errorJustin Bogner2015-07-171-2/+2
| | | | | | | | If this assert does fire, the no-asserts behaviour is an infinite loop. It's better to crash in this case so we get a crash report and stop wasting the user's cpu cycles. llvm-svn: 242591
* Switch users of the 'for (StmtRange range = stmt->children(); range; ↵Benjamin Kramer2015-07-021-4/+3
| | | | | | | | | ++range)‘ pattern to range for loops. The pattern was born out of the lack of range-based for loops in C++98 and is somewhat obscure. No functionality change intended. llvm-svn: 241300
* InstrProf: Add a comment to clarify an argumentJustin Bogner2015-07-021-1/+2
| | | | llvm-svn: 241296
* InstrProf: Pack the coverage mapping structs that we write outJustin Bogner2015-07-021-1/+1
| | | | | | | When we read this data we treat it as unaligned and packed, so we should really be explicit about that when we write it. llvm-svn: 241218
* InstrProf: Fix a crash when an implicit def appears in a macroJustin Bogner2015-06-231-1/+2
| | | | llvm-svn: 240452
* Revert r240270 ("Fixed/added namespace ending comments using clang-tidy").Alexander Kornienko2015-06-221-1/+1
| | | | llvm-svn: 240353
* 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. llvm-svn: 240270
* InstrProf: Fix coverage mapping when "if" is a macroJustin Bogner2015-06-161-0/+3
| | | | | | | | | We were propagating the coverage map into the body of an if statement, but not into the condition thereafter. This is fine as long as the two locations are in the same virtual file, but they won't be when the "if" part of the statement is from a macro and the condition is not. llvm-svn: 239803
* InstrProf: Only disable coverage in built-in macros, not all system macrosJustin Bogner2015-05-141-4/+9
| | | | | | | | | The issue I was trying to solve in r236547 was about built-in macros, but I disabled coverage in all system macros. This is actually a bit of overkill, and makes the display of coverage around system macros degrade unnecessarily. Instead, limit this to builtins specifically. llvm-svn: 237397
* InstrProf: Don't start or end coverage regions inside of system macrosJustin Bogner2015-05-051-4/+4
| | | | | | | | | | | It doesn't make much sense to try to show coverage inside system macros, and source locations in builtins confuses the coverage mapping. Just avoid doing this. Fixes an assert that fired when a __block storage specifier starts a region. llvm-svn: 236547
* InstrProf: Fix a coverage crash where a macro begins in an unreachable blockJustin Bogner2015-05-011-1/+4
| | | | llvm-svn: 236335
OpenPOWER on IntegriCloud