xref: /llvm-project/clang/test/Analysis/getline-cpp.cpp (revision e1d4ddb0c68f69001d7de43d9c678f4d73c1ecba)
1*e1d4ddb0SNagyDonat // RUN: %clang_analyze_cc1 -analyzer-checker=core,unix,debug.ExprInspection -verify %s
2*e1d4ddb0SNagyDonat 
3*e1d4ddb0SNagyDonat // RUN: %clang_analyze_cc1 -analyzer-checker=core,unix,alpha.unix,debug.ExprInspection -verify %s
4*e1d4ddb0SNagyDonat //
5*e1d4ddb0SNagyDonat // expected-no-diagnostics
6*e1d4ddb0SNagyDonat 
7*e1d4ddb0SNagyDonat #include "Inputs/system-header-simulator-cxx.h"
8*e1d4ddb0SNagyDonat 
test_std_getline()9*e1d4ddb0SNagyDonat void test_std_getline() {
10*e1d4ddb0SNagyDonat   std::string userid, comment;
11*e1d4ddb0SNagyDonat   // MallocChecker should not confuse the POSIX function getline() and the
12*e1d4ddb0SNagyDonat   // unrelated C++ standard library function std::getline.
13*e1d4ddb0SNagyDonat   std::getline(std::cin, userid, ' '); // no-crash
14*e1d4ddb0SNagyDonat   std::getline(std::cin, comment); // no-crash
15*e1d4ddb0SNagyDonat }
16