brintos

brintos / llvm-project-archived public Read only

0
0
Text · 838 B · ce75acf Raw
29 lines · cpp
1// RUN: %clang_analyze_cc1 -std=c++14 -analyzer-checker=core,debug.ExprInspection -analyzer-config inline-lambdas=true -verify %s2// RUN: %clang_analyze_cc1 -std=c++17 -analyzer-checker=core,debug.ExprInspection -analyzer-config inline-lambdas=true -verify %s3 4#include "Inputs/system-header-simulator-cxx.h"5 6void clang_analyzer_warnIfReached();7void clang_analyzer_eval(int);8 9// Capture copy elided object.10struct Elided{11  int x = 14;12  Elided(int) {}13};14 15void testCopyElidedObjectCaptured(int x) {16  int r = [e = Elided(x)] {17    return e.x;18  }();19  20  clang_analyzer_eval(r == 14); // expected-warning{{TRUE}}21}22 23static auto MakeUniquePtr() { return std::make_unique<std::vector<int>>(); }24 25void testCopyElidedUniquePtr() {26  [uniquePtr = MakeUniquePtr()] {}();27  clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}}28}29