summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2017-01-14 15:39:46 +0000
committerDimitry Andric <dim@FreeBSD.org>2017-01-14 15:39:46 +0000
commitafed7be32164a598f8172282c249af7266c48b46 (patch)
treed42e47aabc79449fbfcc454836954645f5c03334 /source
parent6f2913059696064e80328b389e44b199c1af526d (diff)
downloadsrc-test2-afed7be32164a598f8172282c249af7266c48b46.tar.gz
src-test2-afed7be32164a598f8172282c249af7266c48b46.zip
Notes
Diffstat (limited to 'source')
-rw-r--r--source/Core/Module.cpp12
-rw-r--r--source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp5
-rw-r--r--source/Plugins/InstrumentationRuntime/ThreadSanitizer/ThreadSanitizerRuntime.cpp3
-rw-r--r--source/Symbol/ClangASTContext.cpp3
-rw-r--r--source/Symbol/Type.cpp87
-rw-r--r--source/Symbol/TypeList.cpp10
-rw-r--r--source/Symbol/TypeMap.cpp10
7 files changed, 67 insertions, 63 deletions
diff --git a/source/Core/Module.cpp b/source/Core/Module.cpp
index 220773b5ad40..28f140b41e1e 100644
--- a/source/Core/Module.cpp
+++ b/source/Core/Module.cpp
@@ -995,8 +995,8 @@ size_t Module::FindTypes(
TypeList &types) {
size_t num_matches = 0;
const char *type_name_cstr = name.GetCString();
- std::string type_scope;
- std::string type_basename;
+ llvm::StringRef type_scope;
+ llvm::StringRef type_basename;
const bool append = true;
TypeClass type_class = eTypeClassAny;
TypeMap typesmap;
@@ -1006,13 +1006,9 @@ size_t Module::FindTypes(
// from the root namespace and implies and exact match. The typenames we
// get back from clang do not start with "::" so we need to strip this off
// in order to get the qualified names to match
+ exact_match = type_scope.consume_front("::");
- if (type_scope.size() >= 2 && type_scope[0] == ':' &&
- type_scope[1] == ':') {
- type_scope.erase(0, 2);
- exact_match = true;
- }
- ConstString type_basename_const_str(type_basename.c_str());
+ ConstString type_basename_const_str(type_basename);
if (FindTypes_Impl(sc, type_basename_const_str, nullptr, append,
max_matches, searched_symbol_files, typesmap)) {
typesmap.RemoveMismatchedTypes(type_scope, type_basename, type_class,
diff --git a/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp b/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp
index f8539379f7da..f60587ed2fff 100644
--- a/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp
+++ b/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp
@@ -346,8 +346,7 @@ bool ASTResultSynthesizer::SynthesizeBodyResult(CompoundStmt *Body,
ExprResult address_of_expr =
m_sema->CreateBuiltinUnaryOp(SourceLocation(), UO_AddrOf, last_expr);
if (address_of_expr.get())
- m_sema->AddInitializerToDecl(result_decl, address_of_expr.get(), true,
- false);
+ m_sema->AddInitializerToDecl(result_decl, address_of_expr.get(), true);
else
return false;
} else {
@@ -359,7 +358,7 @@ bool ASTResultSynthesizer::SynthesizeBodyResult(CompoundStmt *Body,
if (!result_decl)
return false;
- m_sema->AddInitializerToDecl(result_decl, last_expr, true, false);
+ m_sema->AddInitializerToDecl(result_decl, last_expr, true);
}
DC->addDecl(result_decl);
diff --git a/source/Plugins/InstrumentationRuntime/ThreadSanitizer/ThreadSanitizerRuntime.cpp b/source/Plugins/InstrumentationRuntime/ThreadSanitizer/ThreadSanitizerRuntime.cpp
index 3010724306e4..d8a46e5d4550 100644
--- a/source/Plugins/InstrumentationRuntime/ThreadSanitizer/ThreadSanitizerRuntime.cpp
+++ b/source/Plugins/InstrumentationRuntime/ThreadSanitizer/ThreadSanitizerRuntime.cpp
@@ -206,7 +206,8 @@ CreateStackTrace(ValueObjectSP o,
StructuredData::Array *trace = new StructuredData::Array();
ValueObjectSP trace_value_object =
o->GetValueForExpressionPath(trace_item_name.c_str());
- for (int j = 0; j < 8; j++) {
+ size_t count = trace_value_object->GetNumChildren();
+ for (size_t j = 0; j < count; j++) {
addr_t trace_addr =
trace_value_object->GetChildAtIndex(j, true)->GetValueAsUnsigned(0);
if (trace_addr == 0)
diff --git a/source/Symbol/ClangASTContext.cpp b/source/Symbol/ClangASTContext.cpp
index 3d37b7083b74..49b28349fd15 100644
--- a/source/Symbol/ClangASTContext.cpp
+++ b/source/Symbol/ClangASTContext.cpp
@@ -1528,8 +1528,7 @@ ClassTemplateDecl *ClangASTContext::CreateClassTemplateDecl(
*ast,
decl_ctx, // What decl context do we use here? TU? The actual decl
// context?
- SourceLocation(), decl_name, template_param_list, template_cxx_decl,
- nullptr);
+ SourceLocation(), decl_name, template_param_list, template_cxx_decl);
if (class_template_decl) {
if (access_type != eAccessNone)
diff --git a/source/Symbol/Type.cpp b/source/Symbol/Type.cpp
index 2df193fa45e5..80d08bf742fc 100644
--- a/source/Symbol/Type.cpp
+++ b/source/Symbol/Type.cpp
@@ -620,50 +620,59 @@ ConstString Type::GetQualifiedName() {
return GetForwardCompilerType().GetConstTypeName();
}
-bool Type::GetTypeScopeAndBasename(const char *&name_cstr, std::string &scope,
- std::string &basename,
+bool Type::GetTypeScopeAndBasename(const llvm::StringRef& name,
+ llvm::StringRef &scope,
+ llvm::StringRef &basename,
TypeClass &type_class) {
- // Protect against null c string.
-
type_class = eTypeClassAny;
- if (name_cstr && name_cstr[0]) {
- llvm::StringRef name_strref(name_cstr);
- if (name_strref.startswith("struct ")) {
- name_cstr += 7;
- type_class = eTypeClassStruct;
- } else if (name_strref.startswith("class ")) {
- name_cstr += 6;
- type_class = eTypeClassClass;
- } else if (name_strref.startswith("union ")) {
- name_cstr += 6;
- type_class = eTypeClassUnion;
- } else if (name_strref.startswith("enum ")) {
- name_cstr += 5;
- type_class = eTypeClassEnumeration;
- } else if (name_strref.startswith("typedef ")) {
- name_cstr += 8;
- type_class = eTypeClassTypedef;
- }
- const char *basename_cstr = name_cstr;
- const char *namespace_separator = ::strstr(basename_cstr, "::");
- if (namespace_separator) {
- const char *template_arg_char = ::strchr(basename_cstr, '<');
- while (namespace_separator != nullptr) {
- if (template_arg_char &&
- namespace_separator > template_arg_char) // but namespace'd template
- // arguments are still good
- // to go
- break;
- basename_cstr = namespace_separator + 2;
- namespace_separator = strstr(basename_cstr, "::");
- }
- if (basename_cstr > name_cstr) {
- scope.assign(name_cstr, basename_cstr - name_cstr);
- basename.assign(basename_cstr);
- return true;
+ if (name.empty())
+ return false;
+
+ basename = name;
+ if (basename.consume_front("struct "))
+ type_class = eTypeClassStruct;
+ else if (basename.consume_front("class "))
+ type_class = eTypeClassClass;
+ else if (basename.consume_front("union "))
+ type_class = eTypeClassUnion;
+ else if (basename.consume_front("enum "))
+ type_class = eTypeClassEnumeration;
+ else if (basename.consume_front("typedef "))
+ type_class = eTypeClassTypedef;
+
+ size_t namespace_separator = basename.find("::");
+ if (namespace_separator == llvm::StringRef::npos)
+ return false;
+
+ size_t template_begin = basename.find('<');
+ while (namespace_separator != llvm::StringRef::npos) {
+ if (template_begin != llvm::StringRef::npos &&
+ namespace_separator > template_begin) {
+ size_t template_depth = 1;
+ llvm::StringRef template_arg =
+ basename.drop_front(template_begin + 1);
+ while (template_depth > 0 && !template_arg.empty()) {
+ if (template_arg.front() == '<')
+ template_depth++;
+ else if (template_arg.front() == '>')
+ template_depth--;
+ template_arg = template_arg.drop_front(1);
}
+ if (template_depth != 0)
+ return false; // We have an invalid type name. Bail out.
+ if (template_arg.empty())
+ break; // The template ends at the end of the full name.
+ basename = template_arg;
+ } else {
+ basename = basename.drop_front(namespace_separator + 2);
}
+ template_begin = basename.find('<');
+ namespace_separator = basename.find("::");
+ }
+ if (basename.size() < name.size()) {
+ scope = name.take_front(name.size() - basename.size());
+ return true;
}
return false;
}
diff --git a/source/Symbol/TypeList.cpp b/source/Symbol/TypeList.cpp
index 4d32afcb0516..4fcaff3daf90 100644
--- a/source/Symbol/TypeList.cpp
+++ b/source/Symbol/TypeList.cpp
@@ -108,13 +108,13 @@ void TypeList::Dump(Stream *s, bool show_context) {
void TypeList::RemoveMismatchedTypes(const char *qualified_typename,
bool exact_match) {
- std::string type_scope;
- std::string type_basename;
+ llvm::StringRef type_scope;
+ llvm::StringRef type_basename;
TypeClass type_class = eTypeClassAny;
if (!Type::GetTypeScopeAndBasename(qualified_typename, type_scope,
type_basename, type_class)) {
type_basename = qualified_typename;
- type_scope.clear();
+ type_scope = "";
}
return RemoveMismatchedTypes(type_scope, type_basename, type_class,
exact_match);
@@ -145,8 +145,8 @@ void TypeList::RemoveMismatchedTypes(const std::string &type_scope,
ConstString match_type_name_const_str(the_type->GetQualifiedName());
if (match_type_name_const_str) {
const char *match_type_name = match_type_name_const_str.GetCString();
- std::string match_type_scope;
- std::string match_type_basename;
+ llvm::StringRef match_type_scope;
+ llvm::StringRef match_type_basename;
if (Type::GetTypeScopeAndBasename(match_type_name, match_type_scope,
match_type_basename,
match_type_class)) {
diff --git a/source/Symbol/TypeMap.cpp b/source/Symbol/TypeMap.cpp
index 21eb611e7b86..40c6558d5825 100644
--- a/source/Symbol/TypeMap.cpp
+++ b/source/Symbol/TypeMap.cpp
@@ -152,13 +152,13 @@ void TypeMap::Dump(Stream *s, bool show_context) {
void TypeMap::RemoveMismatchedTypes(const char *qualified_typename,
bool exact_match) {
- std::string type_scope;
- std::string type_basename;
+ llvm::StringRef type_scope;
+ llvm::StringRef type_basename;
TypeClass type_class = eTypeClassAny;
if (!Type::GetTypeScopeAndBasename(qualified_typename, type_scope,
type_basename, type_class)) {
type_basename = qualified_typename;
- type_scope.clear();
+ type_scope = "";
}
return RemoveMismatchedTypes(type_scope, type_basename, type_class,
exact_match);
@@ -189,8 +189,8 @@ void TypeMap::RemoveMismatchedTypes(const std::string &type_scope,
ConstString match_type_name_const_str(the_type->GetQualifiedName());
if (match_type_name_const_str) {
const char *match_type_name = match_type_name_const_str.GetCString();
- std::string match_type_scope;
- std::string match_type_basename;
+ llvm::StringRef match_type_scope;
+ llvm::StringRef match_type_basename;
if (Type::GetTypeScopeAndBasename(match_type_name, match_type_scope,
match_type_basename,
match_type_class)) {