diff options
Diffstat (limited to 'contrib/llvm/tools/lldb/source/Symbol/ClangASTContext.cpp')
-rw-r--r-- | contrib/llvm/tools/lldb/source/Symbol/ClangASTContext.cpp | 59 |
1 files changed, 35 insertions, 24 deletions
diff --git a/contrib/llvm/tools/lldb/source/Symbol/ClangASTContext.cpp b/contrib/llvm/tools/lldb/source/Symbol/ClangASTContext.cpp index d851ae7..68bcde8 100644 --- a/contrib/llvm/tools/lldb/source/Symbol/ClangASTContext.cpp +++ b/contrib/llvm/tools/lldb/source/Symbol/ClangASTContext.cpp @@ -11,7 +11,7 @@ // C Includes // C++ Includes -#include <mutex> +#include <mutex> // std::once #include <string> // Other libraries and framework includes @@ -109,13 +109,8 @@ ClangASTContext::ConvertAccessTypeToAccessSpecifier (AccessType access) return AS_none; } - static void -ParseLangArgs -( - LangOptions &Opts, - InputKind IK -) +ParseLangArgs (LangOptions &Opts, InputKind IK, const char* triple) { // FIXME: Cleanup per-file based stuff. @@ -144,6 +139,7 @@ ParseLangArgs LangStd = LangStandard::lang_opencl; break; case IK_CUDA: + case IK_PreprocessedCuda: LangStd = LangStandard::lang_cuda; break; case IK_Asm: @@ -234,7 +230,7 @@ ParseLangArgs // Opts.Exceptions = Args.hasArg(OPT_fexceptions); // Opts.RTTI = !Args.hasArg(OPT_fno_rtti); // Opts.Blocks = Args.hasArg(OPT_fblocks); -// Opts.CharIsSigned = !Args.hasArg(OPT_fno_signed_char); + Opts.CharIsSigned = ArchSpec(triple).CharIsSignedByDefault(); // Opts.ShortWChar = Args.hasArg(OPT_fshort_wchar); // Opts.Freestanding = Args.hasArg(OPT_ffreestanding); // Opts.NoBuiltin = Args.hasArg(OPT_fno_builtin) || Opts.Freestanding; @@ -405,7 +401,14 @@ ClangASTContext::getASTContext() *getIdentifierTable(), *getSelectorTable(), *getBuiltinContext())); - m_ast_ap->InitBuiltinTypes(*getTargetInfo()); + + m_ast_ap->getDiagnostics().setClient(getDiagnosticConsumer(), false); + + // This can be NULL if we don't know anything about the architecture or if the + // target for an architecture isn't enabled in the llvm/clang that we built + TargetInfo *target_info = getTargetInfo(); + if (target_info) + m_ast_ap->InitBuiltinTypes(*target_info); if ((m_callback_tag_decl || m_callback_objc_decl) && m_callback_baton) { @@ -413,8 +416,6 @@ ClangASTContext::getASTContext() //m_ast_ap->getTranslationUnitDecl()->setHasExternalVisibleStorage(); } - m_ast_ap->getDiagnostics().setClient(getDiagnosticConsumer(), false); - GetASTMap().Insert(m_ast_ap.get(), this); } return m_ast_ap.get(); @@ -449,7 +450,7 @@ ClangASTContext::getLanguageOptions() if (m_language_options_ap.get() == nullptr) { m_language_options_ap.reset(new LangOptions()); - ParseLangArgs(*m_language_options_ap, IK_ObjCXX); + ParseLangArgs(*m_language_options_ap, IK_ObjCXX, GetTargetTriple()); // InitializeLangOptions(*m_language_options_ap, IK_ObjCXX); } return m_language_options_ap.get(); @@ -708,7 +709,7 @@ uint32_t ClangASTContext::GetPointerByteSize () { if (m_pointer_byte_size == 0) - m_pointer_byte_size = GetBasicType(lldb::eBasicTypeVoid).GetPointerType().GetByteSize(); + m_pointer_byte_size = GetBasicType(lldb::eBasicTypeVoid).GetPointerType().GetByteSize(nullptr); return m_pointer_byte_size; } @@ -908,7 +909,8 @@ ClangASTContext::GetBuiltinTypeForDWARFEncodingAndBitSize (const char *type_name if (type_name) { if (streq(type_name, "wchar_t") && - QualTypeMatchesBitSize (bit_size, ast, ast->WCharTy)) + QualTypeMatchesBitSize (bit_size, ast, ast->WCharTy) && + (getTargetInfo() && TargetInfo::isTypeSigned (getTargetInfo()->getWCharType()))) return ClangASTType (ast, ast->WCharTy.getAsOpaquePtr()); if (streq(type_name, "void") && QualTypeMatchesBitSize (bit_size, ast, ast->VoidTy)) @@ -951,18 +953,13 @@ ClangASTContext::GetBuiltinTypeForDWARFEncodingAndBitSize (const char *type_name if (QualTypeMatchesBitSize (bit_size, ast, ast->Int128Ty)) return ClangASTType (ast, ast->Int128Ty.getAsOpaquePtr()); break; - + case DW_ATE_signed_char: - if (type_name) + if (ast->getLangOpts().CharIsSigned && type_name && streq(type_name, "char")) { - if (streq(type_name, "signed char")) - { - if (QualTypeMatchesBitSize (bit_size, ast, ast->SignedCharTy)) - return ClangASTType (ast, ast->SignedCharTy.getAsOpaquePtr()); - } + if (QualTypeMatchesBitSize (bit_size, ast, ast->CharTy)) + return ClangASTType (ast, ast->CharTy.getAsOpaquePtr()); } - if (QualTypeMatchesBitSize (bit_size, ast, ast->CharTy)) - return ClangASTType (ast, ast->CharTy.getAsOpaquePtr()); if (QualTypeMatchesBitSize (bit_size, ast, ast->SignedCharTy)) return ClangASTType (ast, ast->SignedCharTy.getAsOpaquePtr()); break; @@ -970,6 +967,14 @@ ClangASTContext::GetBuiltinTypeForDWARFEncodingAndBitSize (const char *type_name case DW_ATE_unsigned: if (type_name) { + if (streq(type_name, "wchar_t")) + { + if (QualTypeMatchesBitSize (bit_size, ast, ast->WCharTy)) + { + if (!(getTargetInfo() && TargetInfo::isTypeSigned (getTargetInfo()->getWCharType()))) + return ClangASTType (ast, ast->WCharTy.getAsOpaquePtr()); + } + } if (strstr(type_name, "long long")) { if (QualTypeMatchesBitSize (bit_size, ast, ast->UnsignedLongLongTy)) @@ -1012,8 +1017,13 @@ ClangASTContext::GetBuiltinTypeForDWARFEncodingAndBitSize (const char *type_name if (QualTypeMatchesBitSize (bit_size, ast, ast->UnsignedInt128Ty)) return ClangASTType (ast, ast->UnsignedInt128Ty.getAsOpaquePtr()); break; - + case DW_ATE_unsigned_char: + if (!ast->getLangOpts().CharIsSigned && type_name && streq(type_name, "char")) + { + if (QualTypeMatchesBitSize (bit_size, ast, ast->CharTy)) + return ClangASTType (ast, ast->CharTy.getAsOpaquePtr()); + } if (QualTypeMatchesBitSize (bit_size, ast, ast->UnsignedCharTy)) return ClangASTType (ast, ast->UnsignedCharTy.getAsOpaquePtr()); if (QualTypeMatchesBitSize (bit_size, ast, ast->UnsignedShortTy)) @@ -1582,6 +1592,7 @@ ClangASTContext::CreateObjCClass SourceLocation(), &ast->Idents.get(name), nullptr, + nullptr, SourceLocation(), /*isForwardDecl,*/ isInternal); |