logic: use wstring in symbol and bookmark names
* use wstring in symbol and bookmark names * fixed setting apppath in windows includes * regard utf8 encoding in shared indexer commands * regard utf8 encoding in shared indexer status
This commit is contained in:
@@ -9,18 +9,18 @@ FilePath CanonicalFilePathCache::getCanonicalFilePath(const clang::FileEntry* en
|
||||
return getCanonicalFilePath(utility::getFileNameOfFileEntry(entry));
|
||||
}
|
||||
|
||||
FilePath CanonicalFilePathCache::getCanonicalFilePath(const std::string& path)
|
||||
FilePath CanonicalFilePathCache::getCanonicalFilePath(const std::wstring& path)
|
||||
{
|
||||
const std::string lowercasePath = utility::toLowerCase(path);
|
||||
const std::wstring lowercasePath = utility::toLowerCase(path);
|
||||
|
||||
std::unordered_map<std::string, FilePath>::const_iterator it = m_map.find(lowercasePath);
|
||||
std::unordered_map<std::wstring, FilePath>::const_iterator it = m_map.find(lowercasePath);
|
||||
if (it != m_map.end())
|
||||
{
|
||||
return it->second;
|
||||
}
|
||||
|
||||
const FilePath canonicalPath = FilePath(path).makeCanonical();
|
||||
const std::string lowercaseCanonicalPath = utility::toLowerCase(canonicalPath.str());
|
||||
const std::wstring lowercaseCanonicalPath = utility::toLowerCase(canonicalPath.wstr());
|
||||
|
||||
m_map.insert(std::make_pair(lowercasePath, canonicalPath));
|
||||
m_map.insert(std::make_pair(lowercaseCanonicalPath, canonicalPath));
|
||||
|
||||
@@ -11,10 +11,10 @@ class CanonicalFilePathCache
|
||||
{
|
||||
public:
|
||||
FilePath getCanonicalFilePath(const clang::FileEntry* entry);
|
||||
FilePath getCanonicalFilePath(const std::string& path);
|
||||
FilePath getCanonicalFilePath(const std::wstring& path);
|
||||
|
||||
private:
|
||||
std::unordered_map<std::string, FilePath> m_map;
|
||||
std::unordered_map<std::wstring, FilePath> m_map;
|
||||
};
|
||||
|
||||
#endif // CANONICAL_FILE_PATH_CACHE_H
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include "data/parser/ParserClient.h"
|
||||
|
||||
#include "data/parser/ParseLocation.h"
|
||||
#include "utility/utilityString.h"
|
||||
|
||||
CxxAstVisitor::CxxAstVisitor(
|
||||
clang::ASTContext* astContext,
|
||||
@@ -41,7 +42,7 @@ CxxAstVisitor::CxxAstVisitor(
|
||||
return declName->toNameHierarchy();
|
||||
}
|
||||
}
|
||||
return NameHierarchy("global", NAME_DELIMITER_UNKNOWN);
|
||||
return NameHierarchy(L"global", NAME_DELIMITER_UNKNOWN);
|
||||
}
|
||||
);
|
||||
m_typeNameCache = std::make_shared<TypeNameCache>([&](const clang::Type* type) -> NameHierarchy
|
||||
@@ -54,7 +55,7 @@ CxxAstVisitor::CxxAstVisitor(
|
||||
return typeName->toNameHierarchy();
|
||||
}
|
||||
}
|
||||
return NameHierarchy("global", NAME_DELIMITER_UNKNOWN);
|
||||
return NameHierarchy(L"global", NAME_DELIMITER_UNKNOWN);
|
||||
}
|
||||
);
|
||||
|
||||
@@ -738,7 +739,7 @@ ParseLocation CxxAstVisitor::getParseLocation(const clang::SourceRange& sourceRa
|
||||
}
|
||||
else
|
||||
{
|
||||
filePath = m_canonicalFilePathCache->getCanonicalFilePath(presumedBegin.getFilename());
|
||||
filePath = m_canonicalFilePathCache->getCanonicalFilePath(utility::decodeFromUtf8(presumedBegin.getFilename()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -146,10 +146,10 @@ void CxxAstVisitorComponentIndexer::beginTraverseLambdaCapture(clang::LambdaExpr
|
||||
if (!d->getNameAsString().empty()) // don't record anonymous parameters
|
||||
{
|
||||
ParseLocation declLocation = getParseLocation(d->getLocation());
|
||||
std::string name =
|
||||
declLocation.filePath.fileName() + "<" +
|
||||
std::to_string(declLocation.startLineNumber) + ":" +
|
||||
std::to_string(declLocation.startColumnNumber) + ">";
|
||||
std::wstring name =
|
||||
declLocation.filePath.wFileName() + L"<" +
|
||||
std::to_wstring(declLocation.startLineNumber) + L":" +
|
||||
std::to_wstring(declLocation.startColumnNumber) + L">";
|
||||
m_client->recordLocalSymbol(name, getParseLocation(capture->getLocation()));
|
||||
}
|
||||
}
|
||||
@@ -233,10 +233,10 @@ void CxxAstVisitorComponentIndexer::visitVarDecl(clang::VarDecl* d)
|
||||
if (!d->getNameAsString().empty()) // don't record anonymous parameters
|
||||
{
|
||||
ParseLocation declLocation = getParseLocation(d->getLocation());
|
||||
std::string name =
|
||||
declLocation.filePath.fileName() + "<" +
|
||||
std::to_string(declLocation.startLineNumber) + ":" +
|
||||
std::to_string(declLocation.startColumnNumber) + ">";
|
||||
std::wstring name =
|
||||
declLocation.filePath.wFileName() + L"<" +
|
||||
std::to_wstring(declLocation.startLineNumber) + L":" +
|
||||
std::to_wstring(declLocation.startColumnNumber) + L">";
|
||||
m_client->recordLocalSymbol(name, getParseLocation(d->getLocation()));
|
||||
}
|
||||
}
|
||||
@@ -474,7 +474,7 @@ void CxxAstVisitorComponentIndexer::visitUsingDirectiveDecl(clang::UsingDirectiv
|
||||
m_client->recordReference(
|
||||
REFERENCE_USAGE,
|
||||
nameHierarchy,
|
||||
getAstVisitor()->getComponent<CxxAstVisitorComponentContext>()->getContextName(NameHierarchy(loc.filePath.str(), NAME_DELIMITER_FILE)),
|
||||
getAstVisitor()->getComponent<CxxAstVisitorComponentContext>()->getContextName(NameHierarchy(loc.filePath.wstr(), NAME_DELIMITER_FILE)),
|
||||
loc
|
||||
);
|
||||
}
|
||||
@@ -488,7 +488,7 @@ void CxxAstVisitorComponentIndexer::visitUsingDecl(clang::UsingDecl* d)
|
||||
m_client->recordReference(
|
||||
REFERENCE_USAGE,
|
||||
getAstVisitor()->getDeclNameCache()->getValue(d),
|
||||
getAstVisitor()->getComponent<CxxAstVisitorComponentContext>()->getContextName(NameHierarchy(loc.filePath.str(), NAME_DELIMITER_FILE)),
|
||||
getAstVisitor()->getComponent<CxxAstVisitorComponentContext>()->getContextName(NameHierarchy(loc.filePath.wstr(), NAME_DELIMITER_FILE)),
|
||||
loc
|
||||
);
|
||||
}
|
||||
@@ -575,9 +575,9 @@ void CxxAstVisitorComponentIndexer::visitDeclRefExpr(clang::DeclRefExpr* s)
|
||||
(clang::isa<clang::VarDecl>(decl) && decl->getParentFunctionOrMethod() != NULL)
|
||||
) {
|
||||
ParseLocation declLocation = getParseLocation(decl->getLocation());
|
||||
std::string name = declLocation.filePath.fileName() + "<" +
|
||||
std::to_string(declLocation.startLineNumber) + ":" +
|
||||
std::to_string(declLocation.startColumnNumber) + ">";
|
||||
std::wstring name = declLocation.filePath.wFileName() + L"<" +
|
||||
std::to_wstring(declLocation.startLineNumber) + L":" +
|
||||
std::to_wstring(declLocation.startColumnNumber) + L">";
|
||||
|
||||
m_client->recordLocalSymbol(name, getParseLocation(s->getLocation()));
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include "data/parser/ParseLocation.h"
|
||||
#include "data/parser/ParserClient.h"
|
||||
#include "utility/file/FileRegister.h"
|
||||
#include "utility/utilityString.h"
|
||||
|
||||
CxxDiagnosticConsumer::CxxDiagnosticConsumer(
|
||||
clang::raw_ostream &os,
|
||||
@@ -93,7 +94,7 @@ void CxxDiagnosticConsumer::HandleDiagnostic(clang::DiagnosticsEngine::Level lev
|
||||
|
||||
m_client->recordError(
|
||||
location,
|
||||
message,
|
||||
utility::decodeFromUtf8(message),
|
||||
level == clang::DiagnosticsEngine::Fatal,
|
||||
m_register->hasFilePath(location.filePath)
|
||||
);
|
||||
|
||||
@@ -24,9 +24,9 @@ namespace
|
||||
return utility::concat({ "clang-tool", "-fsyntax-only" }, args);
|
||||
}
|
||||
|
||||
std::vector<std::string> appendFilePath(const std::vector<std::string>& args, llvm::StringRef fileName)
|
||||
std::vector<std::string> appendFilePath(const std::vector<std::string>& args, llvm::StringRef filePath)
|
||||
{
|
||||
return utility::concat(args, { fileName.str() });
|
||||
return utility::concat(args, { filePath.str() });
|
||||
}
|
||||
|
||||
// custom implementation of clang::runToolOnCodeWithArgs which also sets our custon DiagnosticConsumer
|
||||
@@ -92,9 +92,9 @@ void CxxParser::buildIndex(std::shared_ptr<IndexerCommandCxxCdb> indexerCommand)
|
||||
void CxxParser::buildIndex(std::shared_ptr<IndexerCommandCxxEmpty> indexerCommand)
|
||||
{
|
||||
clang::tooling::CompileCommand compileCommand;
|
||||
compileCommand.Filename = indexerCommand->getSourceFilePath().str();
|
||||
compileCommand.Filename = utility::encodeToUtf8(indexerCommand->getSourceFilePath().wstr());
|
||||
compileCommand.Directory = indexerCommand->getWorkingDirectory().str();
|
||||
compileCommand.CommandLine = prependSyntaxOnlyToolArgs(appendFilePath(getCommandlineArguments(indexerCommand), indexerCommand->getSourceFilePath().str()));
|
||||
compileCommand.CommandLine = prependSyntaxOnlyToolArgs(appendFilePath(getCommandlineArguments(indexerCommand), utility::encodeToUtf8(indexerCommand->getSourceFilePath().wstr())));
|
||||
|
||||
CxxCompilationDatabaseSingle compilationDatabase(compileCommand);
|
||||
runTool(&compilationDatabase, indexerCommand->getSourceFilePath());
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
|
||||
#include "utility/file/FileSystem.h"
|
||||
#include "utility/file/FileRegister.h"
|
||||
#include "utility/utilityString.h"
|
||||
|
||||
PreprocessorCallbacks::PreprocessorCallbacks(
|
||||
clang::SourceManager& sourceManager,
|
||||
@@ -64,8 +65,8 @@ void PreprocessorCallbacks::InclusionDirective(
|
||||
FilePath includedFilePath = m_canonicalFilePathCache->getCanonicalFilePath(fileEntry);
|
||||
if (m_fileRegister->hasFilePath(includedFilePath))
|
||||
{
|
||||
const NameHierarchy referencedNameHierarchy(includedFilePath.str(), NAME_DELIMITER_FILE);
|
||||
const NameHierarchy contextNameHierarchy(m_currentPath.str(), NAME_DELIMITER_FILE);
|
||||
const NameHierarchy referencedNameHierarchy(includedFilePath.wstr(), NAME_DELIMITER_FILE);
|
||||
const NameHierarchy contextNameHierarchy(m_currentPath.wstr(), NAME_DELIMITER_FILE);
|
||||
|
||||
m_client->recordReference(
|
||||
REFERENCE_INCLUDE,
|
||||
@@ -87,7 +88,7 @@ void PreprocessorCallbacks::MacroDefined(const clang::Token& macroNameToken, con
|
||||
return;
|
||||
}
|
||||
|
||||
const NameHierarchy nameHierarchy(macroNameToken.getIdentifierInfo()->getName().str(), NAME_DELIMITER_CXX);
|
||||
const NameHierarchy nameHierarchy(utility::decodeFromUtf8(macroNameToken.getIdentifierInfo()->getName().str()), NAME_DELIMITER_CXX);
|
||||
|
||||
m_client->recordSymbol(
|
||||
nameHierarchy,
|
||||
@@ -136,8 +137,8 @@ void PreprocessorCallbacks::onMacroUsage(const clang::Token& macroNameToken)
|
||||
{
|
||||
const ParseLocation loc = getParseLocation(macroNameToken);
|
||||
|
||||
const NameHierarchy referencedNameHierarchy(macroNameToken.getIdentifierInfo()->getName().str(), NAME_DELIMITER_CXX);
|
||||
const NameHierarchy contextNameHierarchy(loc.filePath.str(), NAME_DELIMITER_FILE);
|
||||
const NameHierarchy referencedNameHierarchy(utility::decodeFromUtf8(macroNameToken.getIdentifierInfo()->getName().str()), NAME_DELIMITER_CXX);
|
||||
const NameHierarchy contextNameHierarchy(loc.filePath.wstr(), NAME_DELIMITER_FILE);
|
||||
|
||||
m_client->recordReference(
|
||||
REFERENCE_MACRO_USAGE,
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
#include "data/parser/cxx/name/CxxDeclName.h"
|
||||
|
||||
//CxxDeclName::CxxDeclName(const std::string& name, const std::vector<std::string>& templateParameterNames)
|
||||
//CxxDeclName::CxxDeclName(const std::wstring& name, const std::vector<std::wstring>& templateParameterNames)
|
||||
// : m_name(name)
|
||||
// , m_templateParameterNames(templateParameterNames)
|
||||
//{
|
||||
//}
|
||||
|
||||
CxxDeclName::CxxDeclName(std::string&& name, std::vector<std::string>&& templateParameterNames)
|
||||
CxxDeclName::CxxDeclName(std::wstring&& name, std::vector<std::wstring>&& templateParameterNames)
|
||||
: m_name(std::move(name))
|
||||
, m_templateParameterNames(std::move(templateParameterNames))
|
||||
{
|
||||
}
|
||||
|
||||
//CxxDeclName::CxxDeclName(
|
||||
// const std::string& name,
|
||||
// const std::vector<std::string>& templateParameterNames,
|
||||
// const std::wstring& name,
|
||||
// const std::vector<std::wstring>& templateParameterNames,
|
||||
// std::shared_ptr<CxxName> parent
|
||||
//)
|
||||
// : CxxName(parent)
|
||||
@@ -24,8 +24,8 @@ CxxDeclName::CxxDeclName(std::string&& name, std::vector<std::string>&& template
|
||||
//}
|
||||
|
||||
CxxDeclName::CxxDeclName(
|
||||
std::string&& name,
|
||||
std::vector<std::string>&& templateParameterNames,
|
||||
std::wstring&& name,
|
||||
std::vector<std::wstring>&& templateParameterNames,
|
||||
std::shared_ptr<CxxName> parent
|
||||
)
|
||||
: CxxName(parent)
|
||||
@@ -36,19 +36,19 @@ CxxDeclName::CxxDeclName(
|
||||
|
||||
NameHierarchy CxxDeclName::toNameHierarchy() const
|
||||
{
|
||||
std::string nameString = m_name;
|
||||
std::wstring nameString = m_name;
|
||||
if (!m_templateParameterNames.empty())
|
||||
{
|
||||
nameString += "<";
|
||||
nameString += L"<";
|
||||
for (size_t i = 0; i < m_templateParameterNames.size(); i++)
|
||||
{
|
||||
if (i != 0)
|
||||
{
|
||||
nameString += ", ";
|
||||
nameString += L", ";
|
||||
}
|
||||
nameString += m_templateParameterNames[i];
|
||||
}
|
||||
nameString += ">";
|
||||
nameString += L">";
|
||||
}
|
||||
|
||||
NameHierarchy ret = getParent() ? getParent()->toNameHierarchy(): NameHierarchy(NAME_DELIMITER_CXX);
|
||||
@@ -57,12 +57,12 @@ NameHierarchy CxxDeclName::toNameHierarchy() const
|
||||
return ret;
|
||||
}
|
||||
|
||||
std::string CxxDeclName::getName() const
|
||||
std::wstring CxxDeclName::getName() const
|
||||
{
|
||||
return m_name;
|
||||
}
|
||||
|
||||
std::vector<std::string> CxxDeclName::getTemplateParameterNames() const
|
||||
std::vector<std::wstring> CxxDeclName::getTemplateParameterNames() const
|
||||
{
|
||||
return m_templateParameterNames;
|
||||
}
|
||||
|
||||
@@ -18,8 +18,8 @@ public:
|
||||
//);
|
||||
|
||||
CxxDeclName(
|
||||
std::string&& name,
|
||||
std::vector<std::string>&& templateParameterNames
|
||||
std::wstring&& name,
|
||||
std::vector<std::wstring>&& templateParameterNames
|
||||
);
|
||||
|
||||
// uncomment this constructor if required, but try to use the one using move constructors for the members
|
||||
@@ -30,19 +30,19 @@ public:
|
||||
//);
|
||||
|
||||
CxxDeclName(
|
||||
std::string&& name,
|
||||
std::vector<std::string>&& templateParameterNames,
|
||||
std::wstring&& name,
|
||||
std::vector<std::wstring>&& templateParameterNames,
|
||||
std::shared_ptr<CxxName> parent
|
||||
);
|
||||
|
||||
virtual NameHierarchy toNameHierarchy() const;
|
||||
|
||||
std::string getName() const;
|
||||
std::vector<std::string> getTemplateParameterNames() const;
|
||||
std::wstring getName() const;
|
||||
std::vector<std::wstring> getTemplateParameterNames() const;
|
||||
|
||||
private:
|
||||
std::string m_name;
|
||||
std::vector<std::string> m_templateParameterNames;
|
||||
std::wstring m_name;
|
||||
std::vector<std::wstring> m_templateParameterNames;
|
||||
};
|
||||
|
||||
#endif // CXX_DECL_NAME_H
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#include "data/parser/cxx/name/CxxFunctionDeclName.h"
|
||||
|
||||
//CxxFunctionDeclName::CxxFunctionDeclName(
|
||||
// const std::string& name,
|
||||
// const std::vector<std::string>& templateParameterNames,
|
||||
// const std::wstring& name,
|
||||
// const std::vector<std::wstring>& templateParameterNames,
|
||||
// std::shared_ptr<CxxTypeName> returnTypeName,
|
||||
// const std::vector<std::shared_ptr<CxxTypeName>>& parameterTypeNames,
|
||||
// const bool isConst,
|
||||
@@ -17,8 +17,8 @@
|
||||
//}
|
||||
|
||||
CxxFunctionDeclName::CxxFunctionDeclName(
|
||||
std::string&& name,
|
||||
std::vector<std::string>&& templateParameterNames,
|
||||
std::wstring&& name,
|
||||
std::vector<std::wstring>&& templateParameterNames,
|
||||
std::shared_ptr<CxxTypeName> returnTypeName,
|
||||
std::vector<std::shared_ptr<CxxTypeName>>&& parameterTypeNames,
|
||||
const bool isConst,
|
||||
@@ -33,8 +33,8 @@ CxxFunctionDeclName::CxxFunctionDeclName(
|
||||
}
|
||||
|
||||
//CxxFunctionDeclName::CxxFunctionDeclName(
|
||||
// const std::string& name,
|
||||
// const std::vector<std::string>& templateParameterNames,
|
||||
// const std::wstring& name,
|
||||
// const std::vector<std::wstring>& templateParameterNames,
|
||||
// std::shared_ptr<CxxTypeName> returnTypeName,
|
||||
// const std::vector<std::shared_ptr<CxxTypeName>>& parameterTypeNames,
|
||||
// const bool isConst,
|
||||
@@ -50,8 +50,8 @@ CxxFunctionDeclName::CxxFunctionDeclName(
|
||||
//}
|
||||
|
||||
CxxFunctionDeclName::CxxFunctionDeclName(
|
||||
std::string&& name,
|
||||
std::vector<std::string>&& templateParameterNames,
|
||||
std::wstring&& name,
|
||||
std::vector<std::wstring>&& templateParameterNames,
|
||||
std::shared_ptr<CxxTypeName> returnTypeName,
|
||||
std::vector<std::shared_ptr<CxxTypeName>>&& parameterTypeNames,
|
||||
const bool isConst,
|
||||
@@ -68,26 +68,26 @@ CxxFunctionDeclName::CxxFunctionDeclName(
|
||||
|
||||
NameHierarchy CxxFunctionDeclName::toNameHierarchy() const
|
||||
{
|
||||
std::string signaturePrefix;
|
||||
std::wstring signaturePrefix;
|
||||
if (m_isStatic)
|
||||
{
|
||||
signaturePrefix += "static ";
|
||||
signaturePrefix += L"static ";
|
||||
}
|
||||
signaturePrefix += CxxTypeName::makeUnsolvedIfNull(m_returnTypeName)->toString();
|
||||
|
||||
std::string signaturePostfix = "(";
|
||||
std::wstring signaturePostfix = L"(";
|
||||
for (size_t i = 0; i < m_parameterTypeNames.size(); i++)
|
||||
{
|
||||
if (i != 0)
|
||||
{
|
||||
signaturePostfix += ", ";
|
||||
signaturePostfix += L", ";
|
||||
}
|
||||
signaturePostfix += CxxTypeName::makeUnsolvedIfNull(m_parameterTypeNames[i])->toString();
|
||||
}
|
||||
signaturePostfix += ")";
|
||||
signaturePostfix += L")";
|
||||
if (m_isConst)
|
||||
{
|
||||
signaturePostfix += " const";
|
||||
signaturePostfix += L" const";
|
||||
}
|
||||
|
||||
NameHierarchy ret = CxxDeclName::toNameHierarchy();
|
||||
|
||||
@@ -12,8 +12,8 @@ class CxxFunctionDeclName: public CxxDeclName
|
||||
public:
|
||||
// uncomment this constructor if required, but try to use the one using move constructors for the members
|
||||
//CxxFunctionDeclName(
|
||||
// const std::string& name,
|
||||
// const std::vector<std::string>& templateParameterNames,
|
||||
// const std::wstring& name,
|
||||
// const std::vector<std::wstring>& templateParameterNames,
|
||||
// std::shared_ptr<CxxTypeName> returnTypeName,
|
||||
// const std::vector<std::shared_ptr<CxxTypeName>>& parameterTypeNames,
|
||||
// const bool isConst,
|
||||
@@ -21,8 +21,8 @@ public:
|
||||
//);
|
||||
|
||||
CxxFunctionDeclName(
|
||||
std::string&& name,
|
||||
std::vector<std::string>&& templateParameterNames,
|
||||
std::wstring&& name,
|
||||
std::vector<std::wstring>&& templateParameterNames,
|
||||
std::shared_ptr<CxxTypeName> returnTypeName,
|
||||
std::vector<std::shared_ptr<CxxTypeName>>&& parameterTypeNames,
|
||||
const bool isConst,
|
||||
@@ -31,8 +31,8 @@ public:
|
||||
|
||||
// uncomment this constructor if required, but try to use the one using move constructors for the members
|
||||
//CxxFunctionDeclName(
|
||||
// const std::string& name,
|
||||
// const std::vector<std::string>& templateParameterNames,
|
||||
// const std::wstring& name,
|
||||
// const std::vector<std::wstring>& templateParameterNames,
|
||||
// std::shared_ptr<CxxTypeName> returnTypeName,
|
||||
// const std::vector<std::shared_ptr<CxxTypeName>>& parameterTypeNames,
|
||||
// const bool isConst,
|
||||
@@ -41,8 +41,8 @@ public:
|
||||
//);
|
||||
|
||||
CxxFunctionDeclName(
|
||||
std::string&& name,
|
||||
std::vector<std::string>&& templateParameterNames,
|
||||
std::wstring&& name,
|
||||
std::vector<std::wstring>&& templateParameterNames,
|
||||
std::shared_ptr<CxxTypeName> returnTypeName,
|
||||
std::vector<std::shared_ptr<CxxTypeName>>&& parameterTypeNames,
|
||||
const bool isConst,
|
||||
|
||||
@@ -25,12 +25,12 @@ bool CxxQualifierFlags::empty() const
|
||||
return m_flags == QUALIFIER_NONE;
|
||||
}
|
||||
|
||||
std::string CxxQualifierFlags::toString() const
|
||||
std::wstring CxxQualifierFlags::toString() const
|
||||
{
|
||||
std::string ret = "";
|
||||
std::wstring ret = L"";
|
||||
if (m_flags & QUALIFIER_CONST)
|
||||
{
|
||||
ret += "const";
|
||||
ret += L"const";
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ public:
|
||||
void removeQualifier(QualifierType qualifier);
|
||||
|
||||
bool empty() const;
|
||||
std::string toString() const;
|
||||
std::wstring toString() const;
|
||||
|
||||
private:
|
||||
char m_flags;
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
#include "data/parser/cxx/name/CxxStaticFunctionDeclName.h"
|
||||
|
||||
//CxxStaticFunctionDeclName::CxxStaticFunctionDeclName(
|
||||
// const std::string& name,
|
||||
// const std::vector<std::string>& templateParameterNames,
|
||||
// const std::wstring& name,
|
||||
// const std::vector<std::wstring>& templateParameterNames,
|
||||
// std::shared_ptr<CxxTypeName> returnTypeName,
|
||||
// const std::vector<std::shared_ptr<CxxTypeName>>& parameterTypeNames,
|
||||
// const std::string& translationUnitFileName
|
||||
// const std::wstring& translationUnitFileName
|
||||
//)
|
||||
// : CxxFunctionDeclName(name, templateParameterNames, returnTypeName, parameterTypeNames, false, true)
|
||||
// , m_translationUnitFileName(translationUnitFileName)
|
||||
@@ -13,11 +13,11 @@
|
||||
//}
|
||||
|
||||
CxxStaticFunctionDeclName::CxxStaticFunctionDeclName(
|
||||
std::string&& name,
|
||||
std::vector<std::string>&& templateParameterNames,
|
||||
std::wstring&& name,
|
||||
std::vector<std::wstring>&& templateParameterNames,
|
||||
std::shared_ptr<CxxTypeName> returnTypeName,
|
||||
std::vector<std::shared_ptr<CxxTypeName>>&& parameterTypeNames,
|
||||
std::string&& translationUnitFileName
|
||||
std::wstring&& translationUnitFileName
|
||||
)
|
||||
: CxxFunctionDeclName(std::move(name), std::move(templateParameterNames), returnTypeName, std::move(parameterTypeNames), false, true)
|
||||
, m_translationUnitFileName(std::move(translationUnitFileName))
|
||||
@@ -25,11 +25,11 @@ CxxStaticFunctionDeclName::CxxStaticFunctionDeclName(
|
||||
}
|
||||
|
||||
//CxxStaticFunctionDeclName::CxxStaticFunctionDeclName(
|
||||
// const std::string& name,
|
||||
// const std::vector<std::string>& templateParameterNames,
|
||||
// const std::wstring& name,
|
||||
// const std::vector<std::wstring>& templateParameterNames,
|
||||
// std::shared_ptr<CxxTypeName> returnTypeName,
|
||||
// const std::vector<std::shared_ptr<CxxTypeName>>& parameterTypeNames,
|
||||
// const std::string& translationUnitFileName,
|
||||
// const std::wstring& translationUnitFileName,
|
||||
// std::shared_ptr<CxxName> parent
|
||||
//)
|
||||
// : CxxFunctionDeclName(name, templateParameterNames, returnTypeName, parameterTypeNames, false, true, parent)
|
||||
@@ -38,11 +38,11 @@ CxxStaticFunctionDeclName::CxxStaticFunctionDeclName(
|
||||
//}
|
||||
|
||||
CxxStaticFunctionDeclName::CxxStaticFunctionDeclName(
|
||||
std::string&& name,
|
||||
std::vector<std::string>&& templateParameterNames,
|
||||
std::wstring&& name,
|
||||
std::vector<std::wstring>&& templateParameterNames,
|
||||
std::shared_ptr<CxxTypeName> returnTypeName,
|
||||
std::vector<std::shared_ptr<CxxTypeName>>&& parameterTypeNames,
|
||||
std::string&& translationUnitFileName,
|
||||
std::wstring&& translationUnitFileName,
|
||||
std::shared_ptr<CxxName> parent
|
||||
)
|
||||
: CxxFunctionDeclName(std::move(name), std::move(templateParameterNames), returnTypeName, std::move(parameterTypeNames), false, true, parent)
|
||||
@@ -57,7 +57,7 @@ NameHierarchy CxxStaticFunctionDeclName::toNameHierarchy() const
|
||||
|
||||
std::shared_ptr<NameElement> nameElement = std::make_shared<NameElement>(
|
||||
ret.back()->getName(),
|
||||
NameElement::Signature(sig.getPrefix(), sig.getPostfix() + " (" + m_translationUnitFileName + ")")
|
||||
NameElement::Signature(sig.getPrefix(), sig.getPostfix() + L" (" + m_translationUnitFileName + L")")
|
||||
);
|
||||
|
||||
ret.pop();
|
||||
|
||||
@@ -8,44 +8,44 @@ class CxxStaticFunctionDeclName: public CxxFunctionDeclName
|
||||
public:
|
||||
// uncomment this constructor if required, but try to use the one using move constructors for the members
|
||||
//CxxStaticFunctionDeclName(
|
||||
// const std::string& name,
|
||||
// const std::vector<std::string>& templateParameterNames,
|
||||
// const std::wstring& name,
|
||||
// const std::vector<std::wstring>& templateParameterNames,
|
||||
// std::shared_ptr<CxxTypeName> returnTypeName,
|
||||
// const std::vector<std::shared_ptr<CxxTypeName>>& parameterTypeNames,
|
||||
// const std::string& translationUnitFileName
|
||||
// const std::wstring& translationUnitFileName
|
||||
//);
|
||||
|
||||
CxxStaticFunctionDeclName(
|
||||
std::string&& name,
|
||||
std::vector<std::string>&& templateParameterNames,
|
||||
std::wstring&& name,
|
||||
std::vector<std::wstring>&& templateParameterNames,
|
||||
std::shared_ptr<CxxTypeName> returnTypeName,
|
||||
std::vector<std::shared_ptr<CxxTypeName>>&& parameterTypeNames,
|
||||
std::string&& translationUnitFileName
|
||||
std::wstring&& translationUnitFileName
|
||||
);
|
||||
|
||||
// uncomment this constructor if required, but try to use the one using move constructors for the members
|
||||
//CxxStaticFunctionDeclName(
|
||||
// const std::string& name,
|
||||
// const std::vector<std::string>& templateParameterNames,
|
||||
// const std::wstring& name,
|
||||
// const std::vector<std::wstring>& templateParameterNames,
|
||||
// std::shared_ptr<CxxTypeName> returnTypeName,
|
||||
// const std::vector<std::shared_ptr<CxxTypeName>>& parameterTypeNames,
|
||||
// const std::string& translationUnitFileName,
|
||||
// const std::wstring& translationUnitFileName,
|
||||
// std::shared_ptr<CxxName> parent
|
||||
//);
|
||||
|
||||
CxxStaticFunctionDeclName(
|
||||
std::string&& name,
|
||||
std::vector<std::string>&& templateParameterNames,
|
||||
std::wstring&& name,
|
||||
std::vector<std::wstring>&& templateParameterNames,
|
||||
std::shared_ptr<CxxTypeName> returnTypeName,
|
||||
std::vector<std::shared_ptr<CxxTypeName>>&& parameterTypeNames,
|
||||
std::string&& translationUnitFileName,
|
||||
std::wstring&& translationUnitFileName,
|
||||
std::shared_ptr<CxxName> parent
|
||||
);
|
||||
|
||||
virtual NameHierarchy toNameHierarchy() const;
|
||||
|
||||
private:
|
||||
std::string m_translationUnitFileName;
|
||||
std::wstring m_translationUnitFileName;
|
||||
};
|
||||
|
||||
#endif // CXX_FUNCTION_DECL_NAME_H
|
||||
|
||||
@@ -7,30 +7,30 @@ std::shared_ptr<CxxTypeName> CxxTypeName::makeUnsolvedIfNull(std::shared_ptr<Cxx
|
||||
return name;
|
||||
}
|
||||
return std::make_shared<CxxTypeName>(
|
||||
"unsolved-type", std::vector<std::string>()
|
||||
L"unsolved-type", std::vector<std::wstring>()
|
||||
);
|
||||
}
|
||||
|
||||
CxxTypeName::Modifier::Modifier(std::string&& symbol)
|
||||
CxxTypeName::Modifier::Modifier(std::wstring&& symbol)
|
||||
: symbol(std::move(symbol))
|
||||
{
|
||||
}
|
||||
|
||||
//CxxTypeName::CxxTypeName(const std::string& name, const std::vector<std::string>& templateArguments)
|
||||
//CxxTypeName::CxxTypeName(const std::wstring& name, const std::vector<std::wstring>& templateArguments)
|
||||
// : m_name(name)
|
||||
// , m_templateArguments(templateArguments)
|
||||
//{
|
||||
//}
|
||||
|
||||
CxxTypeName::CxxTypeName(std::string&& name, std::vector<std::string>&& templateArguments)
|
||||
CxxTypeName::CxxTypeName(std::wstring&& name, std::vector<std::wstring>&& templateArguments)
|
||||
: m_name(std::move(name))
|
||||
, m_templateArguments(std::move(templateArguments))
|
||||
{
|
||||
}
|
||||
|
||||
//CxxTypeName::CxxTypeName(
|
||||
// const std::string& name,
|
||||
// const std::vector<std::string>& templateArguments,
|
||||
// const std::wstring& name,
|
||||
// const std::vector<std::wstring>& templateArguments,
|
||||
// std::shared_ptr<CxxName> parent
|
||||
//)
|
||||
// : CxxName(parent)
|
||||
@@ -40,8 +40,8 @@ CxxTypeName::CxxTypeName(std::string&& name, std::vector<std::string>&& template
|
||||
//}
|
||||
|
||||
CxxTypeName::CxxTypeName(
|
||||
std::string&& name,
|
||||
std::vector<std::string>&& templateArguments,
|
||||
std::wstring&& name,
|
||||
std::vector<std::wstring>&& templateArguments,
|
||||
std::shared_ptr<CxxName> parent
|
||||
)
|
||||
: CxxName(parent)
|
||||
@@ -74,41 +74,41 @@ void CxxTypeName::addModifier(const Modifier& modifier)
|
||||
m_modifiers.push_back(modifier);
|
||||
}
|
||||
|
||||
std::string CxxTypeName::toString() const
|
||||
std::wstring CxxTypeName::toString() const
|
||||
{
|
||||
std::string ret = "";
|
||||
std::wstring ret = L"";
|
||||
if (!m_qualifierFlags.empty())
|
||||
{
|
||||
ret += m_qualifierFlags.toString() + " ";
|
||||
ret += m_qualifierFlags.toString() + L" ";
|
||||
}
|
||||
ret += toNameHierarchy().getQualifiedName();
|
||||
|
||||
for (const Modifier& modifier: m_modifiers)
|
||||
{
|
||||
ret += " " + modifier.symbol;
|
||||
ret += L" " + modifier.symbol;
|
||||
if (!modifier.qualifierFlags.empty())
|
||||
{
|
||||
ret += " " + modifier.qualifierFlags.toString();
|
||||
ret += L" " + modifier.qualifierFlags.toString();
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
std::string CxxTypeName::getTypeNameString() const
|
||||
std::wstring CxxTypeName::getTypeNameString() const
|
||||
{
|
||||
std::string ret = m_name;
|
||||
std::wstring ret = m_name;
|
||||
if (!m_templateArguments.empty())
|
||||
{
|
||||
ret += "<";
|
||||
ret += L"<";
|
||||
for (size_t i = 0; i < m_templateArguments.size(); i++)
|
||||
{
|
||||
if (i != 0)
|
||||
{
|
||||
ret += ", ";
|
||||
ret += L", ";
|
||||
}
|
||||
ret += m_templateArguments[i];
|
||||
}
|
||||
ret += ">";
|
||||
ret += L">";
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -16,32 +16,32 @@ public:
|
||||
|
||||
struct Modifier
|
||||
{
|
||||
Modifier(std::string&& symbol);
|
||||
std::string symbol;
|
||||
Modifier(std::wstring&& symbol);
|
||||
std::wstring symbol;
|
||||
CxxQualifierFlags qualifierFlags;
|
||||
};
|
||||
|
||||
// uncomment this constructor if required, but try to use the one using move constructors for the members
|
||||
//CxxTypeName(
|
||||
// const std::string& name,
|
||||
// const std::vector<std::string>& templateArguments
|
||||
// const std::wstring& name,
|
||||
// const std::vector<std::wstring>& templateArguments
|
||||
//);
|
||||
|
||||
CxxTypeName(
|
||||
std::string&& name,
|
||||
std::vector<std::string>&& templateArguments
|
||||
std::wstring&& name,
|
||||
std::vector<std::wstring>&& templateArguments
|
||||
);
|
||||
|
||||
// uncomment this constructor if required, but try to use the one using move constructors for the members
|
||||
//CxxTypeName(
|
||||
// const std::string& name,
|
||||
// const std::vector<std::string>& templateArguments,
|
||||
// const std::wstring& name,
|
||||
// const std::vector<std::wstring>& templateArguments,
|
||||
// std::shared_ptr<CxxName> parent
|
||||
//);
|
||||
|
||||
CxxTypeName(
|
||||
std::string&& name,
|
||||
std::vector<std::string>&& templateArguments,
|
||||
std::wstring&& name,
|
||||
std::vector<std::wstring>&& templateArguments,
|
||||
std::shared_ptr<CxxName> parent
|
||||
);
|
||||
|
||||
@@ -50,13 +50,13 @@ public:
|
||||
void addQualifier(const CxxQualifierFlags::QualifierType qualifier);
|
||||
void addModifier(const Modifier& modifier);
|
||||
|
||||
std::string toString() const;
|
||||
std::wstring toString() const;
|
||||
|
||||
private:
|
||||
std::string getTypeNameString() const;
|
||||
std::wstring getTypeNameString() const;
|
||||
|
||||
std::string m_name;
|
||||
std::vector<std::string> m_templateArguments;
|
||||
std::wstring m_name;
|
||||
std::vector<std::wstring> m_templateArguments;
|
||||
|
||||
CxxQualifierFlags m_qualifierFlags;
|
||||
std::vector<Modifier> m_modifiers;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#include "data/parser/cxx/name/CxxVariableDeclName.h"
|
||||
|
||||
//CxxVariableDeclName::CxxVariableDeclName(
|
||||
// const std::string& name,
|
||||
// const std::vector<std::string>& templateParameterNames,
|
||||
// const std::wstring& name,
|
||||
// const std::vector<std::wstring>& templateParameterNames,
|
||||
// std::shared_ptr<CxxTypeName> typeName,
|
||||
// bool isStatic
|
||||
//)
|
||||
@@ -13,8 +13,8 @@
|
||||
//}
|
||||
|
||||
CxxVariableDeclName::CxxVariableDeclName(
|
||||
std::string&& name,
|
||||
std::vector<std::string>&& templateParameterNames,
|
||||
std::wstring&& name,
|
||||
std::vector<std::wstring>&& templateParameterNames,
|
||||
std::shared_ptr<CxxTypeName> typeName,
|
||||
bool isStatic
|
||||
)
|
||||
@@ -25,8 +25,8 @@ CxxVariableDeclName::CxxVariableDeclName(
|
||||
}
|
||||
|
||||
//CxxVariableDeclName::CxxVariableDeclName(
|
||||
// const std::string& name,
|
||||
// const std::vector<std::string>& templateParameterNames,
|
||||
// const std::wstring& name,
|
||||
// const std::vector<std::wstring>& templateParameterNames,
|
||||
// std::shared_ptr<CxxTypeName> typeName,
|
||||
// bool isStatic,
|
||||
// std::shared_ptr<CxxName> parent
|
||||
@@ -38,8 +38,8 @@ CxxVariableDeclName::CxxVariableDeclName(
|
||||
//}
|
||||
|
||||
CxxVariableDeclName::CxxVariableDeclName(
|
||||
std::string&& name,
|
||||
std::vector<std::string>&& templateParameterNames,
|
||||
std::wstring&& name,
|
||||
std::vector<std::wstring>&& templateParameterNames,
|
||||
std::shared_ptr<CxxTypeName> typeName,
|
||||
bool isStatic,
|
||||
std::shared_ptr<CxxName> parent
|
||||
@@ -52,14 +52,14 @@ CxxVariableDeclName::CxxVariableDeclName(
|
||||
|
||||
NameHierarchy CxxVariableDeclName::toNameHierarchy() const
|
||||
{
|
||||
std::string signaturePrefix;
|
||||
std::wstring signaturePrefix;
|
||||
if (m_isStatic)
|
||||
{
|
||||
signaturePrefix += "static ";
|
||||
signaturePrefix += L"static ";
|
||||
}
|
||||
signaturePrefix += CxxTypeName::makeUnsolvedIfNull(m_typeName)->toString();
|
||||
|
||||
const std::string signaturePostfix;
|
||||
const std::wstring signaturePostfix;
|
||||
|
||||
NameHierarchy ret = CxxDeclName::toNameHierarchy();
|
||||
std::shared_ptr<NameElement> nameElement = std::make_shared<NameElement>(
|
||||
|
||||
@@ -12,31 +12,31 @@ class CxxVariableDeclName: public CxxDeclName
|
||||
public:
|
||||
// uncomment this constructor if required, but try to use the one using move constructors for the members
|
||||
//CxxVariableDeclName(
|
||||
// const std::string& name,
|
||||
// const std::vector<std::string>& templateParameterNames,
|
||||
// const std::wstring& name,
|
||||
// const std::vector<std::wstring>& templateParameterNames,
|
||||
// std::shared_ptr<CxxTypeName> typeName,
|
||||
// bool isStatic
|
||||
//);
|
||||
|
||||
CxxVariableDeclName(
|
||||
std::string&& name,
|
||||
std::vector<std::string>&& templateParameterNames,
|
||||
std::wstring&& name,
|
||||
std::vector<std::wstring>&& templateParameterNames,
|
||||
std::shared_ptr<CxxTypeName> typeName,
|
||||
bool isStatic
|
||||
);
|
||||
|
||||
// uncomment this constructor if required, but try to use the one using move constructors for the members
|
||||
//CxxVariableDeclName(
|
||||
// const std::string& name,
|
||||
// const std::vector<std::string>& templateParameterNames,
|
||||
// const std::wstring& name,
|
||||
// const std::vector<std::wstring>& templateParameterNames,
|
||||
// std::shared_ptr<CxxTypeName> typeName,
|
||||
// bool isStatic,
|
||||
// std::shared_ptr<CxxName> parent
|
||||
//);
|
||||
|
||||
CxxVariableDeclName(
|
||||
std::string&& name,
|
||||
std::vector<std::string>&& templateParameterNames,
|
||||
std::wstring&& name,
|
||||
std::vector<std::wstring>&& templateParameterNames,
|
||||
std::shared_ptr<CxxTypeName> typeName,
|
||||
bool isStatic,
|
||||
std::shared_ptr<CxxName> parent
|
||||
|
||||
@@ -49,7 +49,7 @@ std::shared_ptr<CxxDeclName> CxxDeclNameResolver::getName(const clang::NamedDecl
|
||||
if (Calls.empty())
|
||||
{
|
||||
declaration = nullptr;
|
||||
declName = std::make_shared<CxxDeclName>("unsolved-lambda", std::vector<std::string>());
|
||||
declName = std::make_shared<CxxDeclName>(L"unsolved-lambda", std::vector<std::wstring>());
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -170,12 +170,12 @@ std::shared_ptr<CxxDeclName> CxxDeclNameResolver::getDeclName(const clang::Named
|
||||
{
|
||||
ScopedSwitcher<const clang::NamedDecl*> switcher(m_currentDecl, declaration);
|
||||
|
||||
std::string declNameString = declaration->getNameAsString();
|
||||
std::wstring declNameString = utility::decodeFromUtf8(declaration->getNameAsString());
|
||||
if (const clang::TagDecl* tagDecl = clang::dyn_cast_or_null<clang::TagDecl>(declaration))
|
||||
{
|
||||
if (const clang::TypedefNameDecl* typedefNameDecl = tagDecl->getTypedefNameForAnonDecl())
|
||||
{
|
||||
declNameString = typedefNameDecl->getNameAsString();
|
||||
declNameString = utility::decodeFromUtf8(typedefNameDecl->getNameAsString());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -196,17 +196,17 @@ std::shared_ptr<CxxDeclName> CxxDeclNameResolver::getDeclName(const clang::Named
|
||||
}
|
||||
else if (declNameString.empty())
|
||||
{
|
||||
std::string symbolKindName = "class";
|
||||
std::wstring symbolKindName = L"class";
|
||||
if (recordDecl->isStruct())
|
||||
{
|
||||
symbolKindName = "struct";
|
||||
symbolKindName = L"struct";
|
||||
}
|
||||
else if (recordDecl->isUnion())
|
||||
{
|
||||
symbolKindName = "union";
|
||||
symbolKindName = L"union";
|
||||
}
|
||||
|
||||
return std::make_shared<CxxDeclName>(getNameForAnonymousSymbol(symbolKindName, declaration), std::vector<std::string>());
|
||||
return std::make_shared<CxxDeclName>(getNameForAnonymousSymbol(symbolKindName, declaration), std::vector<std::wstring>());
|
||||
}
|
||||
else if (const clang::CXXRecordDecl* cxxRecordDecl = clang::dyn_cast_or_null<clang::CXXRecordDecl>(declaration))
|
||||
{
|
||||
@@ -226,7 +226,7 @@ std::shared_ptr<CxxDeclName> CxxDeclNameResolver::getDeclName(const clang::Named
|
||||
}
|
||||
else if (clang::isa<clang::ClassTemplateSpecializationDecl>(declaration))
|
||||
{
|
||||
std::vector<std::string> templateArguments;
|
||||
std::vector<std::wstring> templateArguments;
|
||||
const clang::TemplateArgumentList& templateArgumentList = clang::dyn_cast<clang::ClassTemplateSpecializationDecl>(declaration)->getTemplateArgs();
|
||||
for (size_t i = 0; i < templateArgumentList.size(); i++)
|
||||
{
|
||||
@@ -240,15 +240,15 @@ std::shared_ptr<CxxDeclName> CxxDeclNameResolver::getDeclName(const clang::Named
|
||||
{
|
||||
const clang::FunctionDecl* functionDecl = clang::dyn_cast<clang::FunctionDecl>(declaration);
|
||||
|
||||
std::string functionName = declNameString;
|
||||
std::vector<std::string> templateArguments;
|
||||
std::wstring functionName = declNameString;
|
||||
std::vector<std::wstring> templateArguments;
|
||||
|
||||
if ((clang::dyn_cast_or_null<clang::CXXMethodDecl>(functionDecl)) &&
|
||||
(clang::dyn_cast_or_null<clang::CXXMethodDecl>(functionDecl)->getParent()->isLambda()))
|
||||
{
|
||||
const clang::SourceManager& sourceManager = declaration->getASTContext().getSourceManager();
|
||||
const clang::PresumedLoc& presumedBegin = sourceManager.getPresumedLoc(clang::dyn_cast_or_null<clang::CXXMethodDecl>(functionDecl)->getParent()->getLocStart());
|
||||
functionName = "lambda at " + std::to_string(presumedBegin.getLine()) + ":" + std::to_string(presumedBegin.getColumn());
|
||||
functionName = L"lambda at " + std::to_wstring(presumedBegin.getLine()) + L":" + std::to_wstring(presumedBegin.getColumn());
|
||||
}
|
||||
else if (clang::FunctionTemplateDecl* templateFunctionDeclaration = functionDecl->getDescribedFunctionTemplate())
|
||||
{
|
||||
@@ -319,15 +319,15 @@ std::shared_ptr<CxxDeclName> CxxDeclNameResolver::getDeclName(const clang::Named
|
||||
CxxTypeNameResolver typenNameResolver(getCanonicalFilePathCache(), getIgnoredContextDecls());
|
||||
typenNameResolver.ignoreContextDecl(fieldDecl);
|
||||
std::shared_ptr<CxxTypeName> typeName = CxxTypeName::makeUnsolvedIfNull(typenNameResolver.getName(fieldDecl->getType()));
|
||||
return std::make_shared<CxxVariableDeclName>(std::move(declNameString), std::vector<std::string>(), typeName, false);
|
||||
return std::make_shared<CxxVariableDeclName>(std::move(declNameString), std::vector<std::wstring>(), typeName, false);
|
||||
}
|
||||
else if (clang::isa<clang::NamespaceDecl>(declaration) && clang::dyn_cast<clang::NamespaceDecl>(declaration)->isAnonymousNamespace())
|
||||
{
|
||||
return std::make_shared<CxxDeclName>(getNameForAnonymousSymbol("namespace", declaration), std::vector<std::string>());
|
||||
return std::make_shared<CxxDeclName>(getNameForAnonymousSymbol(L"namespace", declaration), std::vector<std::wstring>());
|
||||
}
|
||||
else if (clang::isa<clang::EnumDecl>(declaration) && declNameString.empty())
|
||||
{
|
||||
return std::make_shared<CxxDeclName>(getNameForAnonymousSymbol("enum", declaration), std::vector<std::string>());
|
||||
return std::make_shared<CxxDeclName>(getNameForAnonymousSymbol(L"enum", declaration), std::vector<std::wstring>());
|
||||
}
|
||||
else if (
|
||||
(
|
||||
@@ -336,11 +336,11 @@ std::shared_ptr<CxxDeclName> CxxDeclNameResolver::getDeclName(const clang::Named
|
||||
clang::isa<clang::TemplateTemplateParmDecl>(declaration)
|
||||
) && declNameString.empty())
|
||||
{
|
||||
return std::make_shared<CxxDeclName>(getNameForAnonymousSymbol("template parameter", declaration), std::vector<std::string>());
|
||||
return std::make_shared<CxxDeclName>(getNameForAnonymousSymbol(L"template parameter", declaration), std::vector<std::wstring>());
|
||||
}
|
||||
else if (clang::isa<clang::ParmVarDecl>(declaration) && declNameString.empty())
|
||||
{
|
||||
return std::make_shared<CxxDeclName>(getNameForAnonymousSymbol("parameter", declaration), std::vector<std::string>());
|
||||
return std::make_shared<CxxDeclName>(getNameForAnonymousSymbol(L"parameter", declaration), std::vector<std::wstring>());
|
||||
}
|
||||
else if (clang::isa<clang::VarDecl>(declaration))
|
||||
{
|
||||
@@ -362,7 +362,7 @@ std::shared_ptr<CxxDeclName> CxxDeclNameResolver::getDeclName(const clang::Named
|
||||
typenNameResolver.ignoreContextDecl(varDecl);
|
||||
std::shared_ptr<CxxTypeName> typeName = CxxTypeName::makeUnsolvedIfNull(typenNameResolver.getName(varDecl->getType()));
|
||||
|
||||
std::string varName = declNameString;
|
||||
std::wstring varName = declNameString;
|
||||
if (utility::getSymbolKind(varDecl) == SYMBOL_GLOBAL_VARIABLE &&
|
||||
varDecl->getStorageClass() == clang::SC_Static)
|
||||
{
|
||||
@@ -370,7 +370,7 @@ std::shared_ptr<CxxDeclName> CxxDeclNameResolver::getDeclName(const clang::Named
|
||||
// may be generated (one for each translation unit) we add the name of the translation unit's source file.
|
||||
// If that global variable definition is const, we add the name of the (maybe header) file that variable is defined in instead. This causes
|
||||
// different instances of the variable that all MUST contain the same value to be merged into a single node in Sourcetrail.
|
||||
std::string scopeFileName = "";
|
||||
std::wstring scopeFileName = L"";
|
||||
{
|
||||
if (varDecl->getType().isConstQualified())
|
||||
{
|
||||
@@ -383,11 +383,11 @@ std::shared_ptr<CxxDeclName> CxxDeclNameResolver::getDeclName(const clang::Named
|
||||
}
|
||||
if (!scopeFileName.empty())
|
||||
{
|
||||
varName = declNameString + " (" + scopeFileName + ")";
|
||||
varName = declNameString + L" (" + scopeFileName + L")";
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<std::string> templateParameterNames;
|
||||
std::vector<std::wstring> templateParameterNames;
|
||||
if (varDecl->getDescribedVarTemplate())
|
||||
{
|
||||
const clang::VarTemplateDecl* templateDeclaration = varDecl->getDescribedVarTemplate();
|
||||
@@ -423,53 +423,53 @@ std::shared_ptr<CxxDeclName> CxxDeclNameResolver::getDeclName(const clang::Named
|
||||
|
||||
if (!declNameString.empty())
|
||||
{
|
||||
return std::make_shared<CxxDeclName>(std::move(declNameString), std::vector<std::string>(), std::shared_ptr<CxxName>());
|
||||
return std::make_shared<CxxDeclName>(std::move(declNameString), std::vector<std::wstring>(), std::shared_ptr<CxxName>());
|
||||
}
|
||||
}
|
||||
|
||||
// LOG_ERROR("could not resolve name of decl at: " + declaration->getLocation().printToString(sourceManager));
|
||||
return std::make_shared<CxxDeclName>(getNameForAnonymousSymbol("symbol", declaration), std::vector<std::string>());
|
||||
return std::make_shared<CxxDeclName>(getNameForAnonymousSymbol(L"symbol", declaration), std::vector<std::wstring>());
|
||||
}
|
||||
|
||||
std::string CxxDeclNameResolver::getTranslationUnitMainFileName(const clang::Decl* declaration)
|
||||
std::wstring CxxDeclNameResolver::getTranslationUnitMainFileName(const clang::Decl* declaration)
|
||||
{
|
||||
const clang::SourceManager& sourceManager = declaration->getASTContext().getSourceManager();
|
||||
clang::FileID fileId = sourceManager.getMainFileID();
|
||||
if (fileId.isValid())
|
||||
{
|
||||
const clang::FileEntry* fileEntry = sourceManager.getFileEntryForID(fileId);
|
||||
return getCanonicalFilePathCache()->getCanonicalFilePath(fileEntry).fileName();
|
||||
return getCanonicalFilePathCache()->getCanonicalFilePath(fileEntry).wFileName();
|
||||
}
|
||||
return "";
|
||||
return L"";
|
||||
}
|
||||
|
||||
std::string CxxDeclNameResolver::getDeclarationFileName(const clang::Decl* declaration)
|
||||
std::wstring CxxDeclNameResolver::getDeclarationFileName(const clang::Decl* declaration)
|
||||
{
|
||||
const clang::SourceManager& sourceManager = declaration->getASTContext().getSourceManager();
|
||||
const clang::FileEntry* fileEntry = sourceManager.getFileEntryForID(sourceManager.getFileID(declaration->getLocStart()));
|
||||
if (fileEntry != nullptr && fileEntry->isValid())
|
||||
{
|
||||
return getCanonicalFilePathCache()->getCanonicalFilePath(fileEntry).fileName();
|
||||
return getCanonicalFilePathCache()->getCanonicalFilePath(fileEntry).wFileName();
|
||||
}
|
||||
return getCanonicalFilePathCache()->getCanonicalFilePath(sourceManager.getPresumedLoc(declaration->getLocStart()).getFilename()).fileName();
|
||||
return getCanonicalFilePathCache()->getCanonicalFilePath(utility::decodeFromUtf8(sourceManager.getPresumedLoc(declaration->getLocStart()).getFilename())).wFileName();
|
||||
}
|
||||
|
||||
std::string CxxDeclNameResolver::getNameForAnonymousSymbol(const std::string& symbolKindName, const clang::Decl* declaration)
|
||||
std::wstring CxxDeclNameResolver::getNameForAnonymousSymbol(const std::wstring& symbolKindName, const clang::Decl* declaration)
|
||||
{
|
||||
const clang::SourceManager& sourceManager = declaration->getASTContext().getSourceManager();
|
||||
const clang::PresumedLoc& presumedBegin = sourceManager.getPresumedLoc(declaration->getLocStart());
|
||||
|
||||
if (presumedBegin.isValid())
|
||||
{
|
||||
return "anonymous " + symbolKindName +
|
||||
" (" + getDeclarationFileName(declaration) + "<" + std::to_string(presumedBegin.getLine()) + ":" + std::to_string(presumedBegin.getColumn()) + ">)";
|
||||
return L"anonymous " + symbolKindName +
|
||||
L" (" + getDeclarationFileName(declaration) + L"<" + std::to_wstring(presumedBegin.getLine()) + L":" + std::to_wstring(presumedBegin.getColumn()) + L">)";
|
||||
}
|
||||
return "anonymous " + symbolKindName;
|
||||
return L"anonymous " + symbolKindName;
|
||||
}
|
||||
|
||||
std::vector<std::string> CxxDeclNameResolver::getTemplateParameterStrings(const clang::TemplateDecl* templateDecl)
|
||||
std::vector<std::wstring> CxxDeclNameResolver::getTemplateParameterStrings(const clang::TemplateDecl* templateDecl)
|
||||
{
|
||||
std::vector<std::string> templateParameterStrings;
|
||||
std::vector<std::wstring> templateParameterStrings;
|
||||
clang::TemplateParameterList* parameterList = templateDecl->getTemplateParameters();
|
||||
for (size_t i = 0; i < parameterList->size(); i++)
|
||||
{
|
||||
@@ -478,13 +478,13 @@ std::vector<std::string> CxxDeclNameResolver::getTemplateParameterStrings(const
|
||||
return templateParameterStrings;
|
||||
}
|
||||
|
||||
std::string CxxDeclNameResolver::getTemplateParameterString(const clang::NamedDecl* parameter)
|
||||
std::wstring CxxDeclNameResolver::getTemplateParameterString(const clang::NamedDecl* parameter)
|
||||
{
|
||||
std::string templateParameterTypeString;
|
||||
std::wstring templateParameterTypeString;
|
||||
|
||||
if (parameter)
|
||||
{
|
||||
clang::Decl::Kind templateParameterKind = parameter->getKind();
|
||||
const clang::Decl::Kind templateParameterKind = parameter->getKind();
|
||||
switch (templateParameterKind)
|
||||
{
|
||||
case clang::Decl::NonTypeTemplateParm:
|
||||
@@ -501,16 +501,16 @@ std::string CxxDeclNameResolver::getTemplateParameterString(const clang::NamedDe
|
||||
break;
|
||||
}
|
||||
|
||||
std::string parameterName = parameter->getName();
|
||||
std::wstring parameterName = utility::decodeFromUtf8(parameter->getName());
|
||||
if (!parameterName.empty())
|
||||
{
|
||||
templateParameterTypeString += " " + parameterName;
|
||||
templateParameterTypeString += L" " + parameterName;
|
||||
}
|
||||
}
|
||||
return templateParameterTypeString;
|
||||
}
|
||||
|
||||
std::string CxxDeclNameResolver::getTemplateParameterTypeString(const clang::NonTypeTemplateParmDecl* parameter)
|
||||
std::wstring CxxDeclNameResolver::getTemplateParameterTypeString(const clang::NonTypeTemplateParmDecl* parameter)
|
||||
{
|
||||
CxxTypeNameResolver typeNameResolver(getCanonicalFilePathCache(), getIgnoredContextDecls());
|
||||
|
||||
@@ -523,49 +523,49 @@ std::string CxxDeclNameResolver::getTemplateParameterTypeString(const clang::Non
|
||||
typeNameResolver.ignoreContextDecl(m_currentDecl);
|
||||
}
|
||||
|
||||
std::string typeString;
|
||||
std::wstring typeString;
|
||||
|
||||
std::shared_ptr<CxxTypeName> typeName = CxxTypeName::makeUnsolvedIfNull(typeNameResolver.getName(parameter->getType()));
|
||||
typeString = typeName->toString();
|
||||
|
||||
if (parameter->isTemplateParameterPack())
|
||||
{
|
||||
typeString += "...";
|
||||
typeString += L"...";
|
||||
}
|
||||
return typeString;
|
||||
}
|
||||
|
||||
std::string CxxDeclNameResolver::getTemplateParameterTypeString(const clang::TemplateTypeParmDecl* parameter)
|
||||
std::wstring CxxDeclNameResolver::getTemplateParameterTypeString(const clang::TemplateTypeParmDecl* parameter)
|
||||
{
|
||||
std::string typeString = (parameter->wasDeclaredWithTypename() ? "typename" : "class");
|
||||
std::wstring typeString = (parameter->wasDeclaredWithTypename() ? L"typename" : L"class");
|
||||
if (parameter->isTemplateParameterPack())
|
||||
{
|
||||
typeString += "...";
|
||||
typeString += L"...";
|
||||
}
|
||||
return typeString;
|
||||
}
|
||||
|
||||
std::string CxxDeclNameResolver::getTemplateParameterTypeString(const clang::TemplateTemplateParmDecl* parameter)
|
||||
std::wstring CxxDeclNameResolver::getTemplateParameterTypeString(const clang::TemplateTemplateParmDecl* parameter)
|
||||
{
|
||||
std::string templateParameterTypeString = "template<";
|
||||
std::wstring templateParameterTypeString = L"template<";
|
||||
clang::TemplateParameterList* parameterList = parameter->getTemplateParameters();
|
||||
for (size_t i = 0; i < parameterList->size(); i++)
|
||||
{
|
||||
templateParameterTypeString += getTemplateParameterString(parameterList->getParam(i));
|
||||
templateParameterTypeString += (i < parameterList->size() - 1) ? ", " : "";
|
||||
templateParameterTypeString += (i < parameterList->size() - 1) ? L", " : L"";
|
||||
}
|
||||
templateParameterTypeString += ">";
|
||||
templateParameterTypeString += " typename"; // TODO: what if template template parameter is defined with class keyword?
|
||||
templateParameterTypeString += L">";
|
||||
templateParameterTypeString += L" typename"; // TODO: what if template template parameter is defined with class keyword?
|
||||
|
||||
if (parameter->isTemplateParameterPack())
|
||||
{
|
||||
templateParameterTypeString += "...";
|
||||
templateParameterTypeString += L"...";
|
||||
}
|
||||
|
||||
return templateParameterTypeString;
|
||||
}
|
||||
|
||||
std::string CxxDeclNameResolver::getTemplateArgumentName(const clang::TemplateArgument& argument)
|
||||
std::wstring CxxDeclNameResolver::getTemplateArgumentName(const clang::TemplateArgument& argument)
|
||||
{
|
||||
CxxTemplateArgumentNameResolver resolver(getCanonicalFilePathCache(), getIgnoredContextDecls());
|
||||
return resolver.getTemplateArgumentName(argument);
|
||||
|
||||
@@ -23,26 +23,26 @@ public:
|
||||
private:
|
||||
std::shared_ptr<CxxName> getContextName(const clang::DeclContext* declaration);
|
||||
std::shared_ptr<CxxDeclName> getDeclName(const clang::NamedDecl* declaration);
|
||||
std::string getTranslationUnitMainFileName(const clang::Decl* declaration);
|
||||
std::string getDeclarationFileName(const clang::Decl* declaration);
|
||||
std::string getNameForAnonymousSymbol(const std::string& symbolKindName, const clang::Decl* declaration);
|
||||
std::vector<std::string> getTemplateParameterStrings(const clang::TemplateDecl* templateDecl);
|
||||
std::wstring getTranslationUnitMainFileName(const clang::Decl* declaration);
|
||||
std::wstring getDeclarationFileName(const clang::Decl* declaration);
|
||||
std::wstring getNameForAnonymousSymbol(const std::wstring& symbolKindName, const clang::Decl* declaration);
|
||||
std::vector<std::wstring> getTemplateParameterStrings(const clang::TemplateDecl* templateDecl);
|
||||
template <typename T>
|
||||
std::vector<std::string> getTemplateParameterStringsOfPatrialSpecialitarion(const T* templateDecl);
|
||||
std::string getTemplateParameterString(const clang::NamedDecl* parameter);
|
||||
std::string getTemplateParameterTypeString(const clang::NonTypeTemplateParmDecl* parameter);
|
||||
std::string getTemplateParameterTypeString(const clang::TemplateTypeParmDecl* parameter);
|
||||
std::string getTemplateParameterTypeString(const clang::TemplateTemplateParmDecl* parameter);
|
||||
std::string getTemplateArgumentName(const clang::TemplateArgument& argument);
|
||||
std::vector<std::wstring> getTemplateParameterStringsOfPatrialSpecialitarion(const T* templateDecl);
|
||||
std::wstring getTemplateParameterString(const clang::NamedDecl* parameter);
|
||||
std::wstring getTemplateParameterTypeString(const clang::NonTypeTemplateParmDecl* parameter);
|
||||
std::wstring getTemplateParameterTypeString(const clang::TemplateTypeParmDecl* parameter);
|
||||
std::wstring getTemplateParameterTypeString(const clang::TemplateTemplateParmDecl* parameter);
|
||||
std::wstring getTemplateArgumentName(const clang::TemplateArgument& argument);
|
||||
|
||||
const clang::NamedDecl* m_currentDecl;
|
||||
};
|
||||
|
||||
|
||||
template <typename T>
|
||||
std::vector<std::string> CxxDeclNameResolver::getTemplateParameterStringsOfPatrialSpecialitarion(const T* partialSpecializationDecl)
|
||||
std::vector<std::wstring> CxxDeclNameResolver::getTemplateParameterStringsOfPatrialSpecialitarion(const T* partialSpecializationDecl)
|
||||
{
|
||||
std::vector<std::string> templateParameterNames;
|
||||
std::vector<std::wstring> templateParameterNames;
|
||||
clang::TemplateParameterList* parameterList = partialSpecializationDecl->getTemplateParameters();
|
||||
unsigned int currentParameterIndex = 0;
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
#include "data/parser/cxx/name_resolver/CxxTypeNameResolver.h"
|
||||
#include "data/parser/cxx/name_resolver/CxxDeclNameResolver.h"
|
||||
#include "utility/utilityString.h"
|
||||
|
||||
CxxSpecifierNameResolver::CxxSpecifierNameResolver(std::shared_ptr<CanonicalFilePathCache> canonicalFilePathCache)
|
||||
: CxxNameResolver(canonicalFilePathCache, std::vector<const clang::Decl*>())
|
||||
@@ -36,7 +37,7 @@ std::shared_ptr<CxxName> CxxSpecifierNameResolver::getName(const clang::NestedNa
|
||||
case clang::NestedNameSpecifier::Identifier:
|
||||
{
|
||||
name = std::make_shared<CxxDeclName>(
|
||||
nestedNameSpecifier->getAsIdentifier()->getName(), std::vector<std::string>()
|
||||
utility::decodeFromUtf8(nestedNameSpecifier->getAsIdentifier()->getName()), std::vector<std::wstring>()
|
||||
);
|
||||
|
||||
if (const clang::NestedNameSpecifier* prefix = nestedNameSpecifier->getPrefix())
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <clang/AST/DeclTemplate.h>
|
||||
|
||||
#include "data/parser/cxx/name_resolver/CxxTypeNameResolver.h"
|
||||
#include "utility/utilityString.h"
|
||||
|
||||
CxxTemplateArgumentNameResolver::CxxTemplateArgumentNameResolver(std::shared_ptr<CanonicalFilePathCache> canonicalFilePathCache)
|
||||
: CxxNameResolver(canonicalFilePathCache, std::vector<const clang::Decl*>())
|
||||
@@ -22,7 +23,7 @@ CxxTemplateArgumentNameResolver::~CxxTemplateArgumentNameResolver()
|
||||
{
|
||||
}
|
||||
|
||||
std::string CxxTemplateArgumentNameResolver::getTemplateArgumentName(const clang::TemplateArgument& argument)
|
||||
std::wstring CxxTemplateArgumentNameResolver::getTemplateArgumentName(const clang::TemplateArgument& argument)
|
||||
{
|
||||
// This doesn't work correctly if the template argument is dependent.
|
||||
// If that's required: build name from depth and index of template arg.
|
||||
@@ -52,25 +53,25 @@ std::string CxxTemplateArgumentNameResolver::getTemplateArgumentName(const clang
|
||||
argument.print(pp, os);
|
||||
const std::string typeName = os.str();
|
||||
|
||||
return typeName;
|
||||
return utility::decodeFromUtf8(typeName);
|
||||
}
|
||||
case clang::TemplateArgument::Pack:
|
||||
{
|
||||
std::string typeName = "<";
|
||||
std::wstring typeName = L"<";
|
||||
llvm::ArrayRef<clang::TemplateArgument> pack = argument.getPackAsArray();
|
||||
for (size_t i = 0; i < pack.size(); i++)
|
||||
{
|
||||
typeName += getTemplateArgumentName(pack[i]);
|
||||
if (i < pack.size() - 1)
|
||||
{
|
||||
typeName += ", ";
|
||||
typeName += L", ";
|
||||
}
|
||||
}
|
||||
typeName += ">";
|
||||
typeName += L">";
|
||||
|
||||
return typeName;
|
||||
}
|
||||
}
|
||||
|
||||
return "";
|
||||
return L"";
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ public:
|
||||
);
|
||||
virtual ~CxxTemplateArgumentNameResolver();
|
||||
|
||||
std::string getTemplateArgumentName(const clang::TemplateArgument& argument);
|
||||
std::wstring getTemplateArgumentName(const clang::TemplateArgument& argument);
|
||||
};
|
||||
|
||||
#endif // CXX_TEMPLATE_ARGUMENT_NAME_RESOLVER_H
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include "data/parser/cxx/name_resolver/CxxSpecifierNameResolver.h"
|
||||
#include "data/parser/cxx/name_resolver/CxxTemplateArgumentNameResolver.h"
|
||||
#include "utility/logging/logging.h"
|
||||
#include "utility/utilityString.h"
|
||||
|
||||
CxxTypeNameResolver::CxxTypeNameResolver(std::shared_ptr<CanonicalFilePathCache> canonicalFilePathCache)
|
||||
: CxxNameResolver(canonicalFilePathCache, std::vector<const clang::Decl*>())
|
||||
@@ -67,7 +68,7 @@ std::shared_ptr<CxxTypeName> CxxTypeNameResolver::getName(const clang::Type* typ
|
||||
{
|
||||
typeName = std::make_shared<CxxTypeName>(
|
||||
declName->getName(),
|
||||
std::vector<std::string>(),
|
||||
std::vector<std::wstring>(),
|
||||
declName->getParent()
|
||||
);
|
||||
}
|
||||
@@ -79,7 +80,7 @@ std::shared_ptr<CxxTypeName> CxxTypeNameResolver::getName(const clang::Type* typ
|
||||
typeName = getName(type->getPointeeType());
|
||||
if (typeName)
|
||||
{
|
||||
typeName->addModifier(CxxTypeName::Modifier("*"));
|
||||
typeName->addModifier(CxxTypeName::Modifier(L"*"));
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -91,7 +92,7 @@ std::shared_ptr<CxxTypeName> CxxTypeNameResolver::getName(const clang::Type* typ
|
||||
typeName = getName(clang::dyn_cast<clang::ArrayType>(type)->getElementType());
|
||||
if (typeName)
|
||||
{
|
||||
typeName->addModifier(CxxTypeName::Modifier("[]"));
|
||||
typeName->addModifier(CxxTypeName::Modifier(L"[]"));
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -100,7 +101,7 @@ std::shared_ptr<CxxTypeName> CxxTypeNameResolver::getName(const clang::Type* typ
|
||||
typeName = getName(type->getPointeeType());
|
||||
if (typeName)
|
||||
{
|
||||
typeName->addModifier(CxxTypeName::Modifier("&"));
|
||||
typeName->addModifier(CxxTypeName::Modifier(L"&"));
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -109,7 +110,7 @@ std::shared_ptr<CxxTypeName> CxxTypeNameResolver::getName(const clang::Type* typ
|
||||
typeName = getName(type->getPointeeType());
|
||||
if (typeName)
|
||||
{
|
||||
typeName->addModifier(CxxTypeName::Modifier("&&"));
|
||||
typeName->addModifier(CxxTypeName::Modifier(L"&&"));
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -140,7 +141,7 @@ std::shared_ptr<CxxTypeName> CxxTypeNameResolver::getName(const clang::Type* typ
|
||||
pp.Bool = true; // value "true": prints bool type as "bool" instead of "_Bool"
|
||||
|
||||
typeName = std::make_shared<CxxTypeName>(
|
||||
type->getAs<clang::BuiltinType>()->getName(pp), std::vector<std::string>()
|
||||
utility::decodeFromUtf8(type->getAs<clang::BuiltinType>()->getName(pp)), std::vector<std::wstring>()
|
||||
);
|
||||
break;
|
||||
}
|
||||
@@ -168,7 +169,7 @@ std::shared_ptr<CxxTypeName> CxxTypeNameResolver::getName(const clang::Type* typ
|
||||
|
||||
if (declName)
|
||||
{
|
||||
std::vector<std::string> templateArguments;
|
||||
std::vector<std::wstring> templateArguments;
|
||||
CxxTemplateArgumentNameResolver resolver(getCanonicalFilePathCache(), getIgnoredContextDecls());
|
||||
resolver.ignoreContextDecl(templateSpecializationType->getTemplateName().getAsTemplateDecl()->getTemplatedDecl());
|
||||
for (size_t i = 0; i < templateSpecializationType->getNumArgs(); i++)
|
||||
@@ -214,9 +215,10 @@ std::shared_ptr<CxxTypeName> CxxTypeNameResolver::getName(const clang::Type* typ
|
||||
|
||||
CxxSpecifierNameResolver specifierNameResolver(getCanonicalFilePathCache(), getIgnoredContextDecls());
|
||||
std::shared_ptr<CxxName> specifierName = specifierNameResolver.getName(dependentType->getQualifier());
|
||||
|
||||
typeName = std::make_shared<CxxTypeName>(
|
||||
dependentType->getIdentifier()->getName().str(), std::vector<std::string>(), specifierName
|
||||
utility::decodeFromUtf8(dependentType->getIdentifier()->getName().str()),
|
||||
std::vector<std::wstring>(),
|
||||
specifierName
|
||||
);
|
||||
break;
|
||||
}
|
||||
@@ -227,7 +229,7 @@ std::shared_ptr<CxxTypeName> CxxTypeNameResolver::getName(const clang::Type* typ
|
||||
CxxSpecifierNameResolver specifierNameResolver(getCanonicalFilePathCache(), getIgnoredContextDecls());
|
||||
std::shared_ptr<CxxName> specifierName = specifierNameResolver.getName(dependentType->getQualifier());
|
||||
|
||||
std::vector<std::string> templateArguments;
|
||||
std::vector<std::wstring> templateArguments;
|
||||
CxxTemplateArgumentNameResolver resolver(getCanonicalFilePathCache(), getIgnoredContextDecls());
|
||||
for (size_t i = 0; i < dependentType->getNumArgs(); i++)
|
||||
{
|
||||
@@ -235,7 +237,9 @@ std::shared_ptr<CxxTypeName> CxxTypeNameResolver::getName(const clang::Type* typ
|
||||
}
|
||||
|
||||
typeName = std::make_shared<CxxTypeName>(
|
||||
dependentType->getIdentifier()->getName().str(), std::move(templateArguments), specifierName
|
||||
utility::decodeFromUtf8(dependentType->getIdentifier()->getName().str()),
|
||||
std::move(templateArguments),
|
||||
specifierName
|
||||
);
|
||||
break;
|
||||
}
|
||||
@@ -254,7 +258,7 @@ std::shared_ptr<CxxTypeName> CxxTypeNameResolver::getName(const clang::Type* typ
|
||||
else
|
||||
{
|
||||
typeName = std::make_shared<CxxTypeName>(
|
||||
"auto", std::vector<std::string>()
|
||||
L"auto", std::vector<std::wstring>() // TODO: can we actually resolve this case? would be great!
|
||||
);
|
||||
}
|
||||
break;
|
||||
@@ -267,20 +271,20 @@ std::shared_ptr<CxxTypeName> CxxTypeNameResolver::getName(const clang::Type* typ
|
||||
case clang::Type::FunctionProto:
|
||||
{
|
||||
const clang::FunctionProtoType* protoType = clang::dyn_cast<clang::FunctionProtoType>(type);
|
||||
std::string nameString = CxxTypeName::makeUnsolvedIfNull(getName(protoType->getReturnType()))->toString();
|
||||
nameString += "(";
|
||||
std::wstring nameString = CxxTypeName::makeUnsolvedIfNull(getName(protoType->getReturnType()))->toString();
|
||||
nameString += L"(";
|
||||
for (size_t i = 0; i < protoType->getNumParams(); i++)
|
||||
{
|
||||
if (i != 0)
|
||||
{
|
||||
nameString += ", ";
|
||||
nameString += L", ";
|
||||
}
|
||||
nameString += CxxTypeName::makeUnsolvedIfNull(getName(protoType->getParamType(i)))->toString();
|
||||
}
|
||||
nameString += ")";
|
||||
nameString += L")";
|
||||
|
||||
typeName = std::make_shared<CxxTypeName>(
|
||||
std::move(nameString), std::vector<std::string>()
|
||||
std::move(nameString), std::vector<std::wstring>()
|
||||
);
|
||||
break;
|
||||
}
|
||||
@@ -292,8 +296,8 @@ std::shared_ptr<CxxTypeName> CxxTypeNameResolver::getName(const clang::Type* typ
|
||||
}
|
||||
default:
|
||||
{
|
||||
std::string typeClassName = type->getTypeClassName();
|
||||
LOG_INFO(std::string("Unhandled kind of type encountered: ") + typeClassName);
|
||||
const std::string typeClassName = type->getTypeClassName();
|
||||
LOG_INFO("Unhandled kind of type encountered: " + typeClassName);
|
||||
clang::PrintingPolicy pp = clang::PrintingPolicy(clang::LangOptions());
|
||||
pp.SuppressTagKeyword = true; // value "true": for a class A it prints "A" instead of "class A"
|
||||
pp.Bool = true; // value "true": prints bool type as "bool" instead of "_Bool"
|
||||
@@ -301,10 +305,10 @@ std::shared_ptr<CxxTypeName> CxxTypeNameResolver::getName(const clang::Type* typ
|
||||
clang::SmallString<64> Buf;
|
||||
llvm::raw_svector_ostream StrOS(Buf);
|
||||
clang::QualType::print(type, clang::Qualifiers(), StrOS, pp, clang::Twine());
|
||||
std::string nameString = StrOS.str();
|
||||
std::wstring nameString = utility::decodeFromUtf8(StrOS.str());
|
||||
|
||||
typeName = std::make_shared<CxxTypeName>(
|
||||
std::move(nameString), std::vector<std::string>()
|
||||
std::move(nameString), std::vector<std::wstring>()
|
||||
);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <clang/AST/DeclTemplate.h>
|
||||
|
||||
#include "utility/file/FilePath.h"
|
||||
#include "utility/utilityString.h"
|
||||
|
||||
bool utility::isImplicit(const clang::Decl* d)
|
||||
{
|
||||
@@ -108,19 +109,19 @@ SymbolKind utility::getSymbolKind(const clang::VarDecl* d)
|
||||
return symbolKind;
|
||||
}
|
||||
|
||||
std::string utility::getFileNameOfFileEntry(const clang::FileEntry* entry)
|
||||
std::wstring utility::getFileNameOfFileEntry(const clang::FileEntry* entry)
|
||||
{
|
||||
std::string fileName = "";
|
||||
std::wstring fileName = L"";
|
||||
if (entry != nullptr && entry->isValid())
|
||||
{
|
||||
fileName = entry->tryGetRealPathName();
|
||||
fileName = utility::decodeFromUtf8(entry->tryGetRealPathName());
|
||||
if (fileName.empty())
|
||||
{
|
||||
fileName = entry->getName();
|
||||
fileName = utility::decodeFromUtf8(entry->getName());
|
||||
}
|
||||
else
|
||||
{
|
||||
fileName = FilePath(entry->getName().str()).getParentDirectory().concatenate(FilePath(fileName).wFileName()).str();
|
||||
fileName = FilePath(utility::decodeFromUtf8(entry->getName().str())).getParentDirectory().concatenate(FilePath(fileName).wFileName()).wstr();
|
||||
}
|
||||
}
|
||||
return fileName;
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace utility
|
||||
AccessKind convertAccessSpecifier(clang::AccessSpecifier access);
|
||||
SymbolKind convertTagKind(const clang::TagTypeKind tagKind);
|
||||
SymbolKind getSymbolKind(const clang::VarDecl* d);
|
||||
std::string getFileNameOfFileEntry(const clang::FileEntry* entry);
|
||||
std::wstring getFileNameOfFileEntry(const clang::FileEntry* entry);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
|
||||
Reference in New Issue
Block a user