[flang] Use c_str() rather than data() where NUL termination is assumed

Original-commit: flang-compiler/f18@5baed3c856
Reviewed-on: https://github.com/flang-compiler/f18/pull/804
This commit is contained in:
peter klausler 2019-10-31 13:25:28 -07:00
parent 0e74840ac2
commit 7a681f46f8
5 changed files with 3 additions and 7 deletions

View File

@ -186,6 +186,8 @@ in `if`/`while` predicates.
When no presence test is obviously protecting a `*x` reference to the
contents, and it is assumed that the contents are present, validate that
assumption by using `x.value()` instead.
1. We use `c_str()` rather than `data()` when converting a `std::string`
to a `const char *` when the result is expected to be NUL-terminated.
#### Classes
1. Define POD structures with `struct`.

View File

@ -18,8 +18,6 @@
#include "../semantics/symbol.h"
#include "../semantics/tools.h"
using namespace std::literals::string_literals;
namespace Fortran::evaluate {
// Constant expression predicate IsConstantExpr().

View File

@ -27,8 +27,6 @@
#include <sstream>
#include <string>
using namespace std::literals::string_literals;
// IsDescriptor() predicate
// TODO there's probably a better place for this predicate than here
namespace Fortran::semantics {

View File

@ -25,8 +25,6 @@
namespace Fortran::parser {
using namespace std::string_literals;
// When SHOW_ALL_SOURCE_MEMBERS is defined, HasSource<T>::value is true if T has
// a member named source
template<typename T, typename = int> struct HasSource : std::false_type {};

View File

@ -1081,7 +1081,7 @@ const char *Prescanner::IsCompilerDirectiveSentinel(
return nullptr;
}
const auto iter{compilerDirectiveSentinels_.find(std::string(sentinel, n))};
return iter == compilerDirectiveSentinels_.end() ? nullptr : iter->data();
return iter == compilerDirectiveSentinels_.end() ? nullptr : iter->c_str();
}
Prescanner::LineClassification Prescanner::ClassifyLine(