summaryrefslogtreecommitdiffstats
path: root/test/CoverageMapping
Commit message (Collapse)AuthorAgeFilesLines
* [Coverage] Avoid null deref in skipRegionMappingForDecl (fixes PR32761)Vedant Kumar2017-04-241-0/+11
| | | | | | | | Patch by Adam Folwarczny! Differential Revision: https://reviews.llvm.org/D32406 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@301249 91177308-0d34-0410-b5e6-96231b3b80d8
* [Coverage] Don't emit mappings for functions in dependent contexts (fixes ↵Vedant Kumar2017-04-191-0/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | | PR32679) The coverage implementation marks functions which won't be emitted as 'deferred', so that it can emit empty coverage regions for them later (once their linkages are known). Functions in dependent contexts are an exception: if there isn't a full instantiation of a function, it shouldn't be marked 'deferred'. We've been breaking that rule without much consequence because we just ended up with useless, extra, empty coverage mappings. With PR32679, this behavior finally caused a crash, because clang marked a partial template specialization as 'deferred', causing the MS mangler to choke in its delayed-template-parsing mode: error: cannot mangle this template type parameter type yet (http://bugs.llvm.org/show_bug.cgi?id=32679) Fix this by checking if a decl's context is a dependent context before marking it 'deferred'. Based on a patch by Adam Folwarczny! Differential Revision: https://reviews.llvm.org/D32144 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@300723 91177308-0d34-0410-b5e6-96231b3b80d8
* clang/test/CoverageMapping/unused_names.c: Relax an expression for targeting ↵NAKAMURA Takumi2017-04-141-1/+1
| | | | | | PECOFF. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@300303 91177308-0d34-0410-b5e6-96231b3b80d8
* Suppress uninteresting warnings in test/CoverageMapping, NFC.Vedant Kumar2017-02-253-3/+3
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@296247 91177308-0d34-0410-b5e6-96231b3b80d8
* [profiling] Update test cases to deal with name variable change (NFC)Vedant Kumar2017-02-141-6/+7
| | | | | | | | | This is a re-try of r295085: fix up some test cases that assume that profile name variables are preserved by the instrprof pass. This catches one additional case in test/CoverageMapping/unused_names.c. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@295101 91177308-0d34-0410-b5e6-96231b3b80d8
* [Coverage] Support for C++17 if initializersVedant Kumar2016-10-141-1/+12
| | | | | | Differential Revision: https://reviews.llvm.org/D25572 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@284293 91177308-0d34-0410-b5e6-96231b3b80d8
* [Coverage] Support for C++17 switch initializersVedant Kumar2016-10-141-6/+16
| | | | | | Differential Revision: https://reviews.llvm.org/D25539 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@284292 91177308-0d34-0410-b5e6-96231b3b80d8
* [Coverage] The coverage region for switch covers the code after the switch.Alex Lorenz2016-09-272-13/+13
| | | | | | | | | | | | | | | 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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@282554 91177308-0d34-0410-b5e6-96231b3b80d8
* [Coverage] Suppress creating a code region if the same area is covered by an ↵Igor Kudrin2016-08-312-7/+10
| | | | | | | | | | | | | 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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@280199 91177308-0d34-0410-b5e6-96231b3b80d8
* [Coverage] Prevent creating a redundant counter if a nested body ends with a ↵Igor Kudrin2016-08-291-0/+12
| | | | | | | | | | | | | | | | | | 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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@279962 91177308-0d34-0410-b5e6-96231b3b80d8
* [Coverage] Do not write out coverage mappings with zero entriesVedant Kumar2016-07-261-3/+6
| | | | | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@276716 91177308-0d34-0410-b5e6-96231b3b80d8
* [Coverage] Attempt to appease a Windows builderVedant Kumar2016-07-221-1/+1
| | | | | | | | | | | | | | | | The builder prints out the following IR: \5CCoverageMapping\5COutput\5Ctest\5Cf1.c The updated test in r276367 expects path separators to be either '/' or '\\', so it chokes on the unexpected "5C" stuff. I'm not sure what that is, but I included a kludge that should work around it. Failing bot: http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/8718 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@276370 91177308-0d34-0410-b5e6-96231b3b80d8
* [Coverage] Strengthen a test caseVedant Kumar2016-07-221-4/+1
| | | | | | | | We should be able to use `mkdir` without turning on `REQUIRES: shell`. Moreover, this test should check for a path separator which precedes the relative filename to make sure that absolute paths are being used. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@276367 91177308-0d34-0410-b5e6-96231b3b80d8
* [Coverage] Remove '..' from filenames *after* getting an absolute pathVedant Kumar2016-07-181-4/+15
| | | | | | | | Failure to do this breaks relative paths which begin with '..'. This issue was caught by the (still nascent) coverage bot. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@275924 91177308-0d34-0410-b5e6-96231b3b80d8
* [Coverage] Normalize '..' out of filename stringsVedant Kumar2016-07-181-0/+7
| | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@275913 91177308-0d34-0410-b5e6-96231b3b80d8
* [Coverage] Do not map regions from system headersVedant Kumar2016-07-111-2/+1
| | | | | | | | | | | | | | | 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). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@275121 91177308-0d34-0410-b5e6-96231b3b80d8
* [Coverage] Push a new region when handling CXXTryStmtsVedant Kumar2016-06-222-1/+20
| | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@273463 91177308-0d34-0410-b5e6-96231b3b80d8
* Reapply [Coverage] Fix an assertion failure if the definition of an unused ↵Igor Kudrin2016-06-073-0/+39
| | | | | | | | | | | | | | | | 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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@271995 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert [Coverage] Fix an assertion failure if the definition of an unused ↵Igor Kudrin2016-06-073-39/+0
| | | | | | | | | function spans multiple files. r271969 The test case fails on Windows. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@271976 91177308-0d34-0410-b5e6-96231b3b80d8
* [Coverage] Fix an assertion failure if the definition of an unused function ↵Igor Kudrin2016-06-073-0/+39
| | | | | | | | | | | | | | 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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@271969 91177308-0d34-0410-b5e6-96231b3b80d8
* [Coverage] Fix crash on a switch partially covered by a macro (PR27948)Vedant Kumar2016-05-311-0/+8
| | | | | | | We have to handle file exits before and after visiting regions in the switch body. Fixes PR27948. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@271308 91177308-0d34-0410-b5e6-96231b3b80d8
* [Lexer] Don't merge macro args from different macro filesVedant Kumar2016-05-192-0/+31
| | | | | | | | | | | | | | | | | | The lexer sets the end location of macro arguments incorrectly *if*, while merging consecutive args to fit into a single SLocEntry, it finds args which come from different macro files. Fix the issue by using separate SLocEntries in this situation. This fixes a code coverage crasher (rdar://problem/26181005). Because the lexer reported end locations for certain macro args incorrectly, we would generate bogus coverage mappings with negative line offsets. Reviewed-by: akyrtzi Differential Revision: http://reviews.llvm.org/D20401 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@270160 91177308-0d34-0410-b5e6-96231b3b80d8
* [Coverage] Fix an issue where a coverage region might not be created for a ↵Igor Kudrin2016-05-041-0/+23
| | | | | | | | | | | | 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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@268511 91177308-0d34-0410-b5e6-96231b3b80d8
* [Coverage] Fix the start/end locations of switch statementsVedant Kumar2016-03-042-14/+24
| | | | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@262697 91177308-0d34-0410-b5e6-96231b3b80d8
* Restrengthen tests relaxed in r259955Xinliang David Li2016-02-172-1/+2
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@261046 91177308-0d34-0410-b5e6-96231b3b80d8
* [Coverage] Fix crash when handling certain macro expansionsVedant Kumar2016-02-081-0/+38
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@260129 91177308-0d34-0410-b5e6-96231b3b80d8
* [PGO] Test case updateXinliang David Li2016-02-052-4/+4
| | | | | | | | | | | | Temporarily relax check in test to avoid breakage for format change in LLVM side. Once that is done, the test case will be retightened. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@259955 91177308-0d34-0410-b5e6-96231b3b80d8
* [PGO] cc1 option name change for profile instrumentationRong Xu2016-02-0442-42/+42
| | | | | | | | | | | | | | This patch changes cc1 option -fprofile-instr-generate to an enum option -fprofile-instrument={clang|none}. It also changes cc1 options -fprofile-instr-generate= to -fprofile-instrument-path=. The driver level option -fprofile-instr-generate and -fprofile-instr-generate= remain intact. This change will pave the way to integrate new PGO instrumentation in IR level. Review: http://reviews.llvm.org/D16730 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@259811 91177308-0d34-0410-b5e6-96231b3b80d8
* [PGO] Cleanup: Use covmap header definition in the template fileXinliang David Li2016-01-031-1/+1
| | | | | | | | | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@256714 91177308-0d34-0410-b5e6-96231b3b80d8
* [PGO] make profile prefix even shorter and more readableXinliang David Li2015-12-152-5/+5
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@255587 91177308-0d34-0410-b5e6-96231b3b80d8
* [PGO] Shorten profile symbol prefixesXinliang David Li2015-12-142-5/+5
| | | | | | | | | | | | (test case update) Profile symbols have long prefixes which waste space and creating pressure for linker. This patch shortens the prefixes to minimal length without losing verbosity. Differential Revision: http://reviews.llvm.org/D15503 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@255576 91177308-0d34-0410-b5e6-96231b3b80d8
* [PGO] Stop using invalid char in instr variable names.Xinliang David Li2015-12-121-1/+1
| | | | | | | | | (This is part-2 of the patch of r255434 -- fixing test cases, second try) git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@255435 91177308-0d34-0410-b5e6-96231b3b80d8
* [PGO] Revert r255366: solution incomplete, not handling lambda yetXinliang David Li2015-12-111-1/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@255368 91177308-0d34-0410-b5e6-96231b3b80d8
* [PGO] Stop using invalid char in instr variable names.Xinliang David Li2015-12-111-1/+1
| | | | | | | | | | | | | | | | | | | (This is part-2 of the patch -- fixing test cases) Before the patch, -fprofile-instr-generate compile will fail if no integrated-as is specified when the file contains any static functions (the -S output is also invalid). This patch fixed the issue. With the change, the index format version will be bumped up by 1. Backward compatibility is preserved with this change. Differential Revision: http://reviews.llvm.org/D15243 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@255366 91177308-0d34-0410-b5e6-96231b3b80d8
* InstrProf: Fix a misuse of the FunctionDecl API when generating coverageJustin Bogner2015-07-281-0/+15
| | | | | | | | | | | This was calling FD->hasBody(), meaning "Does the function that this decl refers to have a body?", rather than FD->doesThisDeclarationHaveABody(), meaning "Is this decl a non-deleted definition?". We might want to consider renaming these APIs :/ git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@243360 91177308-0d34-0410-b5e6-96231b3b80d8
* InstrProf: Fix a typo in the test for r243066Justin Bogner2015-07-231-1/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@243068 91177308-0d34-0410-b5e6-96231b3b80d8
* InstrProf: Don't extend coverage regions into the catch keywordJustin Bogner2015-07-231-0/+24
| | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@243066 91177308-0d34-0410-b5e6-96231b3b80d8
* 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@241218 91177308-0d34-0410-b5e6-96231b3b80d8
* InstrProf: Fix a crash when an implicit def appears in a macroJustin Bogner2015-06-231-0/+16
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@240452 91177308-0d34-0410-b5e6-96231b3b80d8
* InstrProf: Fix coverage mapping when "if" is a macroJustin Bogner2015-06-161-0/+14
| | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@239803 91177308-0d34-0410-b5e6-96231b3b80d8
* InstrProf: Only disable coverage in built-in macros, not all system macrosJustin Bogner2015-05-141-0/+24
| | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@237397 91177308-0d34-0410-b5e6-96231b3b80d8
* InstrProf: Don't start or end coverage regions inside of system macrosJustin Bogner2015-05-051-0/+12
| | | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@236547 91177308-0d34-0410-b5e6-96231b3b80d8
* InstrProf: Fix a coverage crash where a macro begins in an unreachable blockJustin Bogner2015-05-011-0/+15
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@236335 91177308-0d34-0410-b5e6-96231b3b80d8
* InstrProf: Make sure coverage propagates out of foreach loops correctlyJustin Bogner2015-04-301-4/+11
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@236264 91177308-0d34-0410-b5e6-96231b3b80d8
* InstrProf: Mark code regions after throw expressions as unreachableJustin Bogner2015-04-281-6/+8
| | | | | | | We weren't setting regions as being unreachable after C++ throw expressions, leading to incorrect count propagations. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@235967 91177308-0d34-0410-b5e6-96231b3b80d8
* InstrProf: Fix coverage maps for conditional operatorsJustin Bogner2015-04-241-1/+15
| | | | | | | | | This fixes a crash when we're emitting coverage and a macro appears between two binary conditional operators, ie, "foo ?: MACRO ?: bar", and fixes the interaction of macros and conditional operators in general. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@235793 91177308-0d34-0410-b5e6-96231b3b80d8
* InstrProf: Fix a shadowing error that would break length of profile namesJustin Bogner2015-04-231-3/+3
| | | | | | | | We try to use the member variable "FuncName" here, but we've also used that name as a parameter. This ends with us getting the length of the function name wrong when we generate the coverage data. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@235565 91177308-0d34-0410-b5e6-96231b3b80d8
* InstrProf: Handle whitespace and comments at the ends of macrosJustin Bogner2015-03-251-0/+11
| | | | | | | | | | | | | | | When we try to find the end loc for a token, we have to re-lex the token. This was running into a problem when we'd store the end loc of a macro's coverage region, since we wouldn't actually be at the beginning of a token when we tried to re-lex it, leading us to do silly things (and eventually assert) when whitespace or comments followed. This pushes our use of getPreciseTokenLocEnd earlier, so that we won't call it when it doesn't make sense to. It also removes an unnecessary adjustment by 1 that was working around this problem in some cases. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@233169 91177308-0d34-0410-b5e6-96231b3b80d8
* Test case updates for explicit type parameter to the gep operatorDavid Blaikie2015-03-131-1/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@232187 91177308-0d34-0410-b5e6-96231b3b80d8
* InstrProf: Make sure counts in lambdas don't escape to the parent scopeJustin Bogner2015-02-241-0/+17
| | | | | | | | When generating coverage maps, we were traversing the body as if it were part of the parent function, but this doesn't make sense since we're currently counting lambdas as separate functions. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@230304 91177308-0d34-0410-b5e6-96231b3b80d8