Allow getStringType() to reset the cache.
This commit is contained in:
parent
7825094907
commit
aae2870f62
@ -13,6 +13,7 @@
|
||||
#include "llvm/ADT/StringRef.h"
|
||||
#include "llvm/ADT/SmallVector.h"
|
||||
|
||||
#include <array>
|
||||
#include <memory>
|
||||
|
||||
namespace clang {
|
||||
@ -57,7 +58,7 @@ namespace cling {
|
||||
private:
|
||||
std::unique_ptr<clang::Parser> m_Parser;
|
||||
Interpreter* m_Interpreter; // we do not own.
|
||||
const clang::Type* m_StringTy[kNumCachedStrings] = {};
|
||||
std::array<const clang::Type*, kNumCachedStrings> m_StringTy = {};
|
||||
|
||||
public:
|
||||
LookupHelper(clang::Parser* P, Interpreter* interp);
|
||||
|
@ -1910,6 +1910,10 @@ namespace cling {
|
||||
assert(Type && "Type cannot be null");
|
||||
const Transaction*& Cache = m_Interpreter->getStdStringTransaction();
|
||||
if (!Cache || !m_StringTy[kStdString]) {
|
||||
// getStringType can be called multiple times with Cache being null, and
|
||||
// the local cache should be discarded when that occurs.
|
||||
if (!Cache)
|
||||
m_StringTy = {};
|
||||
QualType Qt = findType("std::string", WithDiagnostics);
|
||||
m_StringTy[kStdString] = Qt.isNull() ? nullptr : Qt.getTypePtr();
|
||||
if (!m_StringTy[kStdString]) return kNotAString;
|
||||
|
Loading…
Reference in New Issue
Block a user