diff options
Diffstat (limited to 'clang/lib/CodeGen/CodeGenPGO.cpp')
-rw-r--r-- | clang/lib/CodeGen/CodeGenPGO.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/clang/lib/CodeGen/CodeGenPGO.cpp b/clang/lib/CodeGen/CodeGenPGO.cpp index 37ba0fb8851..4dbd01a6619 100644 --- a/clang/lib/CodeGen/CodeGenPGO.cpp +++ b/clang/lib/CodeGen/CodeGenPGO.cpp @@ -331,9 +331,10 @@ namespace { MapRegionCounters(llvm::DenseMap<const Stmt *, unsigned> &CounterMap) : NextCounter(0), CounterMap(CounterMap) {} - // Do not traverse the BlockDecl inside a BlockExpr since each BlockDecl - // is handled as a separate function. - bool TraverseBlockExpr(BlockExpr *block) { return true; } + // Blocks and lambdas are handled as separate functions, so we need not + // traverse them in the parent context. + bool TraverseBlockExpr(BlockExpr *BE) { return true; } + bool TraverseLambdaBody(LambdaExpr *LE) { return true; } bool VisitDecl(const Decl *D) { switch (D->getKind()) { @@ -431,6 +432,11 @@ namespace { Visit(D->getBody()); } + // Skip lambda expressions. We visit these as FunctionDecls when we're + // generating them and aren't interested in the body when generating a + // parent context. + void VisitLambdaExpr(const LambdaExpr *LE) {} + void VisitObjCMethodDecl(const ObjCMethodDecl *D) { // Counter tracks entry to the method body. RegionCounter Cnt(PGO, D->getBody()); |