Summary: Inject a marker using a global variable in <iostream>, and whitelist it so that the frontend translates it. Use the marker in the SIOF checker to tell whether a file includes <iostream>. If so, start the analysis of its methods assuming that the standard streams are initialised. Reviewed By: sblackshear Differential Revision: D5941343 fbshipit-source-id: 3388d55master
parent
d70babb871
commit
22aca7494b
@ -0,0 +1,15 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2017 - present Facebook, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the BSD style license found in the
|
||||||
|
* LICENSE file in the root directory of this source tree. An additional grant
|
||||||
|
* of patent rights can be found in the PATENTS file in the same directory.
|
||||||
|
*/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include_next <iostream>
|
||||||
|
|
||||||
|
// this is a marker so that infer can tell whether iostream has been included by
|
||||||
|
// a give source file
|
||||||
|
std::ios_base::Init __infer_translation_unit_init_streams;
|
@ -0,0 +1,7 @@
|
|||||||
|
#include <infer_model/portability.h>
|
||||||
|
|
||||||
|
#ifdef INFER_CPP11_ON
|
||||||
|
# include <infer_model/iostream.h>
|
||||||
|
#else
|
||||||
|
# include_next <iostream>
|
||||||
|
#endif
|
@ -0,0 +1,13 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2017 - present Facebook, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the BSD style license found in the
|
||||||
|
* LICENSE file in the root directory of this source tree. An additional grant
|
||||||
|
* of patent rights can be found in the PATENTS file in the same directory.
|
||||||
|
*/
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
void safe_streams() {
|
||||||
|
std::cout << "yay I'm safe thanks to having included <iostream>";
|
||||||
|
}
|
Loading…
Reference in new issue