aboutsummaryrefslogtreecommitdiff
path: root/clang/test/CoverageMapping
AgeCommit message (Collapse)AuthorFilesLines
2017-04-24[Coverage] Avoid null deref in skipRegionMappingForDecl (fixes PR32761)Vedant Kumar1-0/+11
Patch by Adam Folwarczny! Differential Revision: https://reviews.llvm.org/D32406 llvm-svn: 301249
2017-04-19[Coverage] Don't emit mappings for functions in dependent contexts (fixes ↵Vedant Kumar1-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 llvm-svn: 300723
2017-04-14clang/test/CoverageMapping/unused_names.c: Relax an expression for targeting ↵NAKAMURA Takumi1-1/+1
PECOFF. llvm-svn: 300303
2017-02-25Suppress uninteresting warnings in test/CoverageMapping, NFC.Vedant Kumar3-3/+3
llvm-svn: 296247
2017-02-14[profiling] Update test cases to deal with name variable change (NFC)Vedant Kumar1-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. llvm-svn: 295101
2016-10-14[Coverage] Support for C++17 if initializersVedant Kumar1-1/+12
Differential Revision: https://reviews.llvm.org/D25572 llvm-svn: 284293
2016-10-14[Coverage] Support for C++17 switch initializersVedant Kumar1-6/+16
Differential Revision: https://reviews.llvm.org/D25539 llvm-svn: 284292
2016-09-27[Coverage] The coverage region for switch covers the code after the switch.Alex Lorenz2-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 llvm-svn: 282554
2016-08-31[Coverage] Suppress creating a code region if the same area is covered by an ↵Igor Kudrin2-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 llvm-svn: 280199
2016-08-29[Coverage] Prevent creating a redundant counter if a nested body ends with a ↵Igor Kudrin1-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 llvm-svn: 279962
2016-07-26[Coverage] Do not write out coverage mappings with zero entriesVedant Kumar1-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. llvm-svn: 276716
2016-07-22[Coverage] Attempt to appease a Windows builderVedant Kumar1-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 llvm-svn: 276370
2016-07-22[Coverage] Strengthen a test caseVedant Kumar1-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. llvm-svn: 276367
2016-07-18[Coverage] Remove '..' from filenames *after* getting an absolute pathVedant Kumar1-4/+15
Failure to do this breaks relative paths which begin with '..'. This issue was caught by the (still nascent) coverage bot. llvm-svn: 275924
2016-07-18[Coverage] Normalize '..' out of filename stringsVedant Kumar1-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. llvm-svn: 275913
2016-07-11[Coverage] Do not map regions from system headersVedant Kumar1-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). llvm-svn: 275121
2016-06-22[Coverage] Push a new region when handling CXXTryStmtsVedant Kumar2-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. llvm-svn: 273463
2016-06-07Reapply [Coverage] Fix an assertion failure if the definition of an unused ↵Igor Kudrin3-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 llvm-svn: 271995
2016-06-07Revert [Coverage] Fix an assertion failure if the definition of an unused ↵Igor Kudrin3-39/+0
function spans multiple files. r271969 The test case fails on Windows. llvm-svn: 271976
2016-06-07[Coverage] Fix an assertion failure if the definition of an unused function ↵Igor Kudrin3-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 llvm-svn: 271969
2016-05-31[Coverage] Fix crash on a switch partially covered by a macro (PR27948)Vedant Kumar1-0/+8
We have to handle file exits before and after visiting regions in the switch body. Fixes PR27948. llvm-svn: 271308
2016-05-19[Lexer] Don't merge macro args from different macro filesVedant Kumar2-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 llvm-svn: 270160
2016-05-04[Coverage] Fix an issue where a coverage region might not be created for a ↵Igor Kudrin1-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 llvm-svn: 268511
2016-03-04[Coverage] Fix the start/end locations of switch statementsVedant Kumar2-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. llvm-svn: 262697
2016-02-17Restrengthen tests relaxed in r259955Xinliang David Li2-1/+2
llvm-svn: 261046
2016-02-08[Coverage] Fix crash when handling certain macro expansionsVedant Kumar1-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 llvm-svn: 260129
2016-02-05[PGO] Test case updateXinliang David Li2-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. llvm-svn: 259955
2016-02-04[PGO] cc1 option name change for profile instrumentationRong Xu42-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 llvm-svn: 259811
2016-01-03[PGO] Cleanup: Use covmap header definition in the template fileXinliang David Li1-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. llvm-svn: 256714
2015-12-15[PGO] make profile prefix even shorter and more readableXinliang David Li2-5/+5
llvm-svn: 255587
2015-12-14[PGO] Shorten profile symbol prefixesXinliang David Li2-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 llvm-svn: 255576
2015-12-12[PGO] Stop using invalid char in instr variable names.Xinliang David Li1-1/+1
(This is part-2 of the patch of r255434 -- fixing test cases, second try) llvm-svn: 255435
2015-12-11[PGO] Revert r255366: solution incomplete, not handling lambda yetXinliang David Li1-1/+1
llvm-svn: 255368
2015-12-11[PGO] Stop using invalid char in instr variable names.Xinliang David Li1-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 llvm-svn: 255366
2015-07-28InstrProf: Fix a misuse of the FunctionDecl API when generating coverageJustin Bogner1-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 :/ llvm-svn: 243360
2015-07-23InstrProf: Fix a typo in the test for r243066Justin Bogner1-1/+1
llvm-svn: 243068
2015-07-23InstrProf: Don't extend coverage regions into the catch keywordJustin Bogner1-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. llvm-svn: 243066
2015-07-02InstrProf: Pack the coverage mapping structs that we write outJustin Bogner1-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
2015-06-23InstrProf: Fix a crash when an implicit def appears in a macroJustin Bogner1-0/+16
llvm-svn: 240452
2015-06-16InstrProf: Fix coverage mapping when "if" is a macroJustin Bogner1-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. llvm-svn: 239803
2015-05-14InstrProf: Only disable coverage in built-in macros, not all system macrosJustin Bogner1-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. llvm-svn: 237397
2015-05-05InstrProf: Don't start or end coverage regions inside of system macrosJustin Bogner1-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. llvm-svn: 236547
2015-05-01InstrProf: Fix a coverage crash where a macro begins in an unreachable blockJustin Bogner1-0/+15
llvm-svn: 236335
2015-04-30InstrProf: Make sure coverage propagates out of foreach loops correctlyJustin Bogner1-4/+11
llvm-svn: 236264
2015-04-28InstrProf: Mark code regions after throw expressions as unreachableJustin Bogner1-6/+8
We weren't setting regions as being unreachable after C++ throw expressions, leading to incorrect count propagations. llvm-svn: 235967
2015-04-24InstrProf: Fix coverage maps for conditional operatorsJustin Bogner1-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. llvm-svn: 235793
2015-04-23InstrProf: Fix a shadowing error that would break length of profile namesJustin Bogner1-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. llvm-svn: 235565
2015-03-25InstrProf: Handle whitespace and comments at the ends of macrosJustin Bogner1-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. llvm-svn: 233169
2015-03-13Test case updates for explicit type parameter to the gep operatorDavid Blaikie1-1/+1
llvm-svn: 232187
2015-02-24InstrProf: Make sure counts in lambdas don't escape to the parent scopeJustin Bogner1-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. llvm-svn: 230304