summaryrefslogtreecommitdiff
path: root/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
AgeCommit message (Collapse)Author
2025-04-01[lldb] Prefer PointerType::get with LLVMContext over Type (NFC) (#133869)Mats Jun Larsen
Part of #123569
2025-03-05[lldb] Upgrade CompilerType::GetBitSize to return llvm::Expected (#129601)Adrian Prantl
This patch pushes the error handling boundary for the GetBitSize() methods from Runtime into the Type and CompilerType APIs. This makes it easier to diagnose problems thanks to more meaningful error messages being available. GetBitSize() is often the first thing LLDB asks about a type, so this method is particularly important for a better user experience. rdar://145667239
2025-01-27[NFC][DebugInfo] Make some block-start-position methods return iterators ↵Jeremy Morse
(#124287) As part of the "RemoveDIs" work to eliminate debug intrinsics, we're replacing methods that use Instruction*'s as positions with iterators. A number of these (such as getFirstNonPHIOrDbg) are sufficiently infrequently used that we can just replace the pointer-returning version with an iterator-returning version, hopefully without much/any disruption. Thus this patch has getFirstNonPHIOrDbg and getFirstNonPHIOrDbgOrLifetime return an iterator, and updates all call-sites. There are no concerns about the iterators returned being converted to Instruction*'s and losing the debug-info bit: because the methods skip debug intrinsics, the iterator head bit is always false anyway.
2024-10-15[lldb] Use BasicBlock::iterator instead of InsertPosition (NFC) (#112307)Jonas Devlieghere
InsertPosition has been deprecated in favor of using BasicBlock::iterator. (See #102608)
2024-09-16[lldb] Nits on uses of llvm::raw_string_ostream (NFC) (#108745)Youngsuk Kim
As specified in the docs, 1) raw_string_ostream is always unbuffered and 2) the underlying buffer may be used directly ( 65b13610a5226b84889b923bae884ba395ad084d for further reference ) * Don't call raw_string_ostream::flush(), which is essentially a no-op. * Avoid unneeded calls to raw_string_ostream::str(), to avoid excess indirection.
2024-08-12[lldb] Avoid calling DataLayout constructor accepting Module pointer (NFC) ↵Sergei Barannikov
(#102839) The constructor initializes `*this` with a copy of `M->getDataLayout()`, which can just be spelled as `DataLayout DL = M->getDataLayout()`. In all places where the constructor is used, Module outlives DataLayout, so store a reference to it instead of cloning. Pull Request: https://github.com/llvm/llvm-project/pull/102839
2024-05-16[lldb] Use operator==(StringRef, StringRef) instead of StringRef::equals ↵Kazu Hirata
(NFC) (#92476) Note that StringRef::equals has been deprecated in favor of operator==(StringRef, StringRef).
2023-12-16[lldb] Use StringRef::{starts,ends}_with (NFC)Kazu Hirata
This patch replaces uses of StringRef::{starts,ends}with with StringRef::{starts,ends}_with for consistency with std::{string,string_view}::{starts,ends}_with in C++20. I'm planning to deprecate and eventually remove StringRef::{starts,ends}with.
2023-11-07[lldb] Fix calls to Type::getInt8PtrTy (#71561)Paulo Matos
These have been removed in 7b9d73c2f90c0ed8497339a16fc39785349d9610. This is a followup patch to apply the changes to lldb.
2023-10-28[lldb] Remove some declarations without definitions (#70514)Sergei Barannikov
The corresponding definitions were removed in 7dcbe3d3 and 2a8fa2a8. Also remove a couple of variables made dead by those changes.
2023-06-30[lldb] Delete RewriteObjCClassReferences (NFC)Dave Lee
The `RewriteObjCClassReferences` pass was applicable only to the code generated for the fragile ObjC ABI (v1). That ABI is no longer active (last used for i386 macOS), which means this pass has no effect. Sources: `OBJC_CLASS_REFERENCES_` is emitted only by `CGObjCMac`, and not by `CGObjCNonFragileABIMac`. Differential Revision: https://reviews.llvm.org/D153802
2023-06-27[lldb] Fix search & replace mistake in IRForTarget comment (NFC)Dave Lee
See 1b95a6ff95a279de27d5f63de8d67a731f280b44
2023-03-17[LLDB] Remove some typed pointer code (NFCI)Nikita Popov
Various bitcast handling should no longer be necessary with opaque pointers.
2023-01-07[lldb] Use std::optional instead of llvm::Optional (NFC)Kazu Hirata
This patch replaces (llvm::|)Optional< with std::optional<. I'll post a separate patch to clean up the "using" declarations, #include "llvm/ADT/Optional.h", etc. This is part of an effort to migrate from llvm::Optional to std::optional: https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
2023-01-07[lldb] Add #include <optional> (NFC)Kazu Hirata
This patch adds #include <optional> to those files containing llvm::Optional<...> or Optional<...>. I'll post a separate patch to actually replace llvm::Optional with std::optional. This is part of an effort to migrate from llvm::Optional to std::optional: https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
2022-06-19[lldb] Use value_or instead of getValueOr (NFC)Kazu Hirata
2022-06-02Adapt IRForTarget::RewriteObjCConstStrings() for D126689.Adrian Prantl
With opaque pointers, the LLVM IR expected by this function changed.
2022-06-02Adapt IRForTarget::RewriteObjCSelector() for D126689.Adrian Prantl
With opaque pointers, the LLVM IR expected by this function changed.
2022-03-24[lldb] Avoid pointer element type accessesNikita Popov
2022-02-14[lldb] Remove some uses of getPointerElementType()Nikita Popov
While in the area, remove some uses of getPointerElementType() that have obvious replacements.
2022-02-14[lldb] Remove uses of PointerType::getElementType()Nikita Popov
This method has been deprecated and removed. I missed these usages in lldb previously.
2022-02-03[lldb] Rename Logging.h to LLDBLog.h and clean up includesPavel Labath
Most of our code was including Log.h even though that is not where the "lldb" log channel is defined (Log.h defines the generic logging infrastructure). This worked because Log.h included Logging.h, even though it should. After the recent refactor, it became impossible the two files include each other in this direction (the opposite inclusion is needed), so this patch removes the workaround that was put in place and cleans up all files to include the right thing. It also renames the file to LLDBLog to better reflect its purpose.
2022-02-02[lldb] Convert "LLDB" log channel to the new APIPavel Labath
2021-12-24Use isa instead of dyn_cast (NFC)Kazu Hirata
2021-10-07[lldb, mlir] Migrate from getNumArgOperands and arg_operands (NFC)Kazu Hirata
Note that getNumArgOperands and arg_operands are considered legacy names. See llvm/include/llvm/IR/InstrTypes.h for details.
2021-07-09[IR] Add GEPOperator::indices() (NFC)Nikita Popov
In order to mirror the GetElementPtrInst::indices() API. Wanted to use this in the IRForTarget code, and was surprised to find that it didn't exist yet.
2021-07-09[IRForTarget] Don't pass nullptr to GetElementPtrInst::Create() (NFC)Nikita Popov
In one case use the source element type of the original GEP. In the other the correct type isn't obvious to me, so use getPointerElementType() for now.
2021-07-02[lldb] Replace default bodies of special member functions with = default;Jonas Devlieghere
Replace default bodies of special member functions with = default; $ run-clang-tidy.py -header-filter='lldb' -checks='-*,modernize-use-equals-default' -fix , https://clang.llvm.org/extra/clang-tidy/checks/modernize-use-equals-default.html Differential revision: https://reviews.llvm.org/D104041
2021-05-25[lldb][NFC] Remove misleading ModulePass base class for IRForTargetRaphael Isemann
IRForTarget is never used by a pass manager or any other interface that requires this class to inherit from `Pass`. Also IRForTarget doesn't implement the current interface correctly because it uses the `runOnModule` return value to indicate success/failure instead of changed/not-changed, so if this ever ends up being used as a pass it would most likely not work as intended. Reviewed By: JDevlieghere Differential Revision: https://reviews.llvm.org/D102677
2021-05-18[lldb][NFC] Cleanup IRForTarget member initializersRaphael Isemann
Note that the FunctionCallee members aren't pointer, so the nullptr was just an alternative way to call the default constructor.
2020-07-22Thread ExecutionContextScope through GetByteSize where possible (NFC-ish)Adrian Prantl
This patch has no effect for C and C++. In more dynamic languages, such as Objective-C and Swift GetByteSize() needs to call into the language runtime, so it's important to pass one in where possible. My primary motivation for this is some work I'm doing on the Swift branch, however, it looks like we are also seeing warnings in Objective-C that this may resolve. Everything in the SymbolFile hierarchy still passes in nullptrs, because we don't have an execution context in SymbolFile, since SymbolFile transcends processes. Differential Revision: https://reviews.llvm.org/D84267
2020-06-24[lldb] Use std::make_unique<> (NFC)Jonas Devlieghere
Update the rest of lldb to use std::make_unique<>. I used clang-tidy to automate this, which probably missed cases that are wrapped in ifdefs.
2020-04-27[IR] Replace all uses of CallBase::getCalledValue() with getCalledOperand().Craig Topper
This method has been commented as deprecated for a while. Remove it and replace all uses with the equivalent getCalledOperand(). I also made a few cleanups in here. For example, to removes use of getElementType on a pointer when we could just use getFunctionType from the call. Differential Revision: https://reviews.llvm.org/D78882
2020-04-10[lldb] Reformat 'Fix breakage introduced by llvm::LoadInst api change' (NFC)Med Ismail Bennani
2020-04-10[lldb] Fix breakeage introduced by llvm::LoadInst api changeMed Ismail Bennani
2020-03-16[lldb] Re-add nullptr check to IRForTarget::RewriteObjCConstString log statementRaphael Isemann
The nullptr check here was removed in 4ef50a33b12825593a82ca8ea97158b7b71b348e when I replaced (nearly) all log->Print to LLDB_LOG calls (which automatically check for this stuff). But it seems this one call escaped my sed call. Currently working on a test that can cover this code path but we can revert this until I have found one.
2020-01-31[lldb] Move clang-based files out of SymbolAlex Langford
Summary: This change represents the move of ClangASTImporter, ClangASTMetadata, ClangExternalASTSourceCallbacks, ClangUtil, CxxModuleHandler, and TypeSystemClang from lldbSource to lldbPluginExpressionParserClang.h This explicitly removes knowledge of clang internals from lldbSymbol, moving towards a more generic core implementation of lldb. Reviewers: JDevlieghere, davide, aprantl, teemperor, clayborg, labath, jingham, shafik Subscribers: emaste, mgorny, arphaman, jfb, usaxena95, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D73661
2020-01-30[lldb][NFC] Remove TypeSystemClang::GetASTContext calls in IRForTargetRaphael Isemann
Similar to previous commits, this just replaces the lookup in the global map with the reference to the TypeSystemClang instance we already have in this context.
2020-01-28Make llvm::StringRef to std::string conversions explicit.Benjamin Kramer
This is how it should've been and brings it more in line with std::string_view. There should be no functional change here. This is mostly mechanical from a custom clang-tidy check, with a lot of manual fixups. It uncovers a lot of minor inefficiencies. This doesn't actually modify StringRef yet, I'll do that in a follow-up.
2020-01-24[lldb][NFC] Fix all formatting errors in .cpp file headersRaphael Isemann
Summary: A *.cpp file header in LLDB (and in LLDB) should like this: ``` //===-- TestUtilities.cpp -------------------------------------------------===// ``` However in LLDB most of our source files have arbitrary changes to this format and these changes are spreading through LLDB as folks usually just use the existing source files as templates for their new files (most notably the unnecessary editor language indicator `-*- C++ -*-` is spreading and in every review someone is pointing out that this is wrong, resulting in people pointing out that this is done in the same way in other files). This patch removes most of these inconsistencies including the editor language indicators, all the different missing/additional '-' characters, files that center the file name, missing trailing `===//` (mostly caused by clang-format breaking the line). Reviewers: aprantl, espindola, jfb, shafik, JDevlieghere Reviewed By: JDevlieghere Subscribers: dexonsmith, wuzish, emaste, sdardis, nemanjai, kbarton, MaskRay, atanasyan, arphaman, jfb, abidh, jsji, JDevlieghere, usaxena95, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D73258
2020-01-23[lldb][NFC] Rename ClangASTContext to TypeSystemClangRaphael Isemann
Summary: This commit renames ClangASTContext to TypeSystemClang to better reflect what this class is actually supposed to do (implement the TypeSystem interface for Clang). It also gets rid of the very confusing situation that we have both a `clang::ASTContext` and a `ClangASTContext` in clang (which sometimes causes Clang people to think I'm fiddling with Clang's ASTContext when I'm actually just doing LLDB work). I also have plans to potentially have multiple clang::ASTContext instances associated with one ClangASTContext so the ASTContext naming will then become even more confusing to people. Reviewers: #lldb, aprantl, shafik, clayborg, labath, JDevlieghere, davide, espindola, jdoerfert, xiaobai Reviewed By: clayborg, labath, xiaobai Subscribers: wuzish, emaste, nemanjai, mgorny, kbarton, MaskRay, arphaman, jfb, usaxena95, jingham, xiaobai, abidh, JDevlieghere, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D72684
2019-12-21[lldb] Fix ARM32 inferior callsJan Kratochvil
echo -e '#include <unistd.h>\nint main(void){\nsync();return 0;}'|./bin/clang -g -x c -;./bin/lldb -o 'file ./a.out' -o 'b main' -o r -o 'p (void)sync()' Actual: error: Expression can't be run, because there is no JIT compiled function Expected: <nothing, sync() has been executed> This patch has been checked by: D71707: clang-tidy: new bugprone-pointer-cast-widening https://reviews.llvm.org/D71707 Casting from 32-bit `void *` to `uint64_t` requires an intermediate `uintptr_t` cast otherwise the pointer gets sign-extended: echo -e '#include <stdio.h>\n#include <stdint.h>\nint main(void){void *p=(void *)0x80000000;unsigned long long ull=(unsigned long long)p;unsigned long long ull2=(unsigned long long)(uintptr_t)p;printf("p=%p ull=0x%llx ull2=0x%llx\\n",p,ull,ull2);return 0;}'|gcc -Wall -m32 -x c -;./a.out <stdin>: In function ‘main’: <stdin>:3:66: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast] p=0x80000000 ull=0xffffffff80000000 ull2=0x80000000 With debug output: Actual: IRMemoryMap::WriteMemory (0xb6ff8640, 0xffffffffb6f82158, 0x112) went to [0xb6ff8640..0xb6ff86b3) Code can be run in the target. Found function, has local address 0xffffffffb6f84000 and remote address 0xffffffffffffffff Couldn't disassemble function : Couldn't find code range for function _Z12$__lldb_exprPv Sections: [0xb6f84000+0x3c]->0xb6ff9020 (alignment 4, section ID 0, name .text) ... HandleCommand, command did not succeed error: Expression can't be run, because there is no JIT compiled function Expected: IRMemoryMap::WriteMemory (0xb6ff8640, 0xb6faa15c, 0x128) went to [0xb6ff8640..0xb6ff86c3) IRExecutionUnit::GetRemoteAddressForLocal() found 0xb6fac000 in [0xb6fac000..0xb6fac040], and returned 0xb6ff9020 from [0xb6ff9020..0xb6ff9060]. Code can be run in the target. Found function, has local address 0xb6fac000 and remote address 0xb6ff9020 Function's code range is [0xb6ff9020+0x40] ... Function data has contents: 0xb6ff9020: 10 4c 2d e9 08 b0 8d e2 08 d0 4d e2 00 40 a0 e1 ... Function disassembly: 0xb6ff9020: 0xe92d4c10 push {r4, r10, r11, lr} Differential revision: https://reviews.llvm.org/D71498
2019-08-17[lldb][NFC] Remove unused MaterializeInitializer and MaterializeInternalVariableRaphael Isemann
llvm-svn: 369198
2019-08-14Revert "[lldb] Reinstate original guard variable check"Raphael Isemann
It seems this breaks the following tests: lldb-Suite :: expression_command/call-function/TestCallUserDefinedFunction.py lldb-Suite :: expression_command/rdar42038760/TestScalarURem.py Let's revert this patch and wait until we find an actual issue that could be fixed by also doing the guard variable check on Windows. llvm-svn: 368920
2019-08-14[lldb] Reinstate original guard variable checkRaphael Isemann
The isGuardVariableSymbol option for ignoring Microsoft's ABI was originally added to get the bots green, but now that we found the actual issue (that we checked for prefix instead of suffix in the MS ABI check), we should be able to properly implement the guard variable check without any strange Microsoft exceptions. llvm-svn: 368802
2019-08-13[Symbol] Decouple clang from CompilerTypeAlex Langford
Summary: Ideally CompilerType would have no knowledge of clang or any individual TypeSystem. Decoupling clang is relatively straightforward. Differential Revision: https://reviews.llvm.org/D66102 llvm-svn: 368741
2019-08-13[lldb] Fix Microsoft guard variable detectionRaphael Isemann
Apparently we need to check for a suffix, not a prefix. This broke probably broke expression evaluation on Windows. llvm-svn: 368695
2019-08-13[lldb] Reland "Refactor guard variable checks in IRForTarget"Raphael Isemann
It seems the broken guard variable check for Windows was a feature(TM) and not a bug, so let's keep add a flag to the guard check that keeps the old behavior in the places where we ignored guard variables before. llvm-svn: 368688
2019-08-12[CompilerType] Pass an ExecutionContextScope to GetTypeBitAlign.Davide Italiano
llvm-svn: 368620
2019-08-12Revert "[lldb] Refactor guard variable checks in IRForTarget"Stella Stamenova
This reverts commit 94fbbf712e906464f5f3abbeabcfcbc05d5352ec. llvm-svn: 368616