mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-16 12:06:36 +00:00

This reapplies 80ab8234ac309418637488b97e0a62d8377b2ecf again, after fixing a name collision warning in the unit tests (see the revert commit 13ccaf9b9d4400bb128b35ff4ac733e4afc3ad1c for 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
|
|
}
|