This reapplies80ab8234acagain, after fixing a name collision warning in the unit tests (see the revert commit13ccaf9b9dfor details). In addition to the previously applied changes, this commit also clarifies the code in MallocChecker that distinguishes POSIX "getline()" and C++ standard library "std::getline()" (which are two completely different functions). Note that "std::getline()" was (accidentally) handled correctly even without this clarification; but it's better to explicitly handle and test this corner case. --------- Co-authored-by: Balazs Benics <benicsbalazs@gmail.com>
16 lines
557 B
C++
16 lines
557 B
C++
// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix,debug.ExprInspection -verify %s
|
|
|
|
// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix,alpha.unix,debug.ExprInspection -verify %s
|
|
//
|
|
// expected-no-diagnostics
|
|
|
|
#include "Inputs/system-header-simulator-cxx.h"
|
|
|
|
void test_std_getline() {
|
|
std::string userid, comment;
|
|
// MallocChecker should not confuse the POSIX function getline() and the
|
|
// unrelated C++ standard library function std::getline.
|
|
std::getline(std::cin, userid, ' '); // no-crash
|
|
std::getline(std::cin, comment); // no-crash
|
|
}
|