Skip to content

Commit 52736a4

Browse files
author
z1_cciauto
authored
merge main into amd-staging (llvm#3745)
2 parents 2697bfc + 6075100 commit 52736a4

File tree

307 files changed

+19123
-679
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

307 files changed

+19123
-679
lines changed

clang-tools-extra/clangd/ModulesBuilder.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,21 @@
1414
#include "clang/Serialization/ASTReader.h"
1515
#include "clang/Serialization/ModuleCache.h"
1616
#include "llvm/ADT/ScopeExit.h"
17+
#include "llvm/Support/CommandLine.h"
18+
1719
#include <queue>
1820

1921
namespace clang {
2022
namespace clangd {
2123

2224
namespace {
2325

26+
llvm::cl::opt<bool> DebugModulesBuilder(
27+
"debug-modules-builder",
28+
llvm::cl::desc("Don't remove clangd's built module files for debugging. "
29+
"Remember to remove them later after debugging."),
30+
llvm::cl::init(false));
31+
2432
// Create a path to store module files. Generally it should be:
2533
//
2634
// {TEMP_DIRS}/clangd/module_files/{hashed-file-name}-%%-%%-%%-%%-%%-%%/.
@@ -122,7 +130,7 @@ struct ModuleFile {
122130
}
123131

124132
~ModuleFile() {
125-
if (!ModuleFilePath.empty())
133+
if (!ModuleFilePath.empty() && !DebugModulesBuilder)
126134
llvm::sys::fs::remove(ModuleFilePath);
127135
}
128136

@@ -315,7 +323,7 @@ buildModuleFile(llvm::StringRef ModuleName, PathRef ModuleUnitFileName,
315323
Cmds += Arg;
316324
}
317325

318-
clangd::vlog("Failed to compile {0} with command: {1}.", ModuleUnitFileName,
326+
clangd::vlog("Failed to compile {0} with command: {1}", ModuleUnitFileName,
319327
Cmds);
320328

321329
std::string BuiltModuleFilesStr = BuiltModuleFiles.getAsString();

clang/include/clang/Basic/CodeGenOptions.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ ENUM_CODEGENOPT(FramePointer, FramePointerKind, 2, FramePointerKind::None, Benig
5858

5959
ENUM_CODEGENOPT(ExceptionHandling, ExceptionHandlingKind, 3, ExceptionHandlingKind::None, NotCompatible)
6060

61-
CODEGENOPT(ClearASTBeforeBackend , 1, 0, Benign) ///< Free the AST before running backend code generation. Only works with -disable-free.
61+
CODEGENOPT(ClearASTBeforeBackend , 1, 0, Benign) ///< Free the AST before running backend code generation.
6262
CODEGENOPT(DisableFree , 1, 0, Benign) ///< Don't free memory.
6363
CODEGENOPT(DiscardValueNames , 1, 0, Benign) ///< Discard Value Names from the IR (LLVMContext flag)
6464
CODEGENOPT(DisableLLVMPasses , 1, 0, Benign) ///< Don't run any LLVM IR passes to get

clang/include/clang/Interpreter/Interpreter.h

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ class ThreadSafeContext;
3737
namespace clang {
3838

3939
class CompilerInstance;
40-
class CodeGenerator;
4140
class CXXRecordDecl;
4241
class Decl;
4342
class IncrementalExecutor;
@@ -110,10 +109,6 @@ class Interpreter {
110109
// printing happens, it's in an invalid state.
111110
Value LastValue;
112111

113-
/// When CodeGen is created the first llvm::Module gets cached in many places
114-
/// and we must keep it alive.
115-
std::unique_ptr<llvm::Module> CachedInCodeGenModule;
116-
117112
/// Compiler instance performing the incremental compilation.
118113
std::unique_ptr<CompilerInstance> CI;
119114

@@ -175,15 +170,9 @@ class Interpreter {
175170
llvm::Expected<llvm::orc::ExecutorAddr>
176171
getSymbolAddressFromLinkerName(llvm::StringRef LinkerName) const;
177172

178-
std::unique_ptr<llvm::Module> GenModule(IncrementalAction *Action = nullptr);
179-
PartialTranslationUnit &RegisterPTU(TranslationUnitDecl *TU,
180-
std::unique_ptr<llvm::Module> M = {},
181-
IncrementalAction *Action = nullptr);
182-
183173
private:
184174
size_t getEffectivePTUSize() const;
185175
void markUserCodeStart();
186-
llvm::Expected<Expr *> ExtractValueFromExpr(Expr *E);
187176

188177
// A cache for the compiled destructors used to for de-allocation of managed
189178
// clang::Values.
@@ -206,11 +195,6 @@ class Interpreter {
206195
// This function forces emission of the needed dtor.
207196
llvm::Expected<llvm::orc::ExecutorAddr>
208197
CompileDtorCall(CXXRecordDecl *CXXRD) const;
209-
210-
/// @}
211-
/// @name Code generation
212-
/// @{
213-
CodeGenerator *getCodeGen(IncrementalAction *Action = nullptr) const;
214198
};
215199
} // namespace clang
216200

clang/lib/AST/ByteCode/Compiler.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5230,6 +5230,12 @@ bool Compiler<Emitter>::VisitCallExpr(const CallExpr *E) {
52305230
const Function *Func = getFunction(FuncDecl);
52315231
if (!Func)
52325232
return false;
5233+
5234+
// In error cases, the function may be called with fewer arguments than
5235+
// parameters.
5236+
if (E->getNumArgs() < Func->getNumWrittenParams())
5237+
return false;
5238+
52335239
assert(HasRVO == Func->hasRVO());
52345240

52355241
bool HasQualifier = false;

clang/lib/AST/ByteCode/Interp.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2117,8 +2117,8 @@ bool DiagTypeid(InterpState &S, CodePtr OpPC) {
21172117

21182118
bool arePotentiallyOverlappingStringLiterals(const Pointer &LHS,
21192119
const Pointer &RHS) {
2120-
unsigned LHSOffset = LHS.getIndex();
2121-
unsigned RHSOffset = RHS.getIndex();
2120+
unsigned LHSOffset = LHS.isOnePastEnd() ? LHS.getNumElems() : LHS.getIndex();
2121+
unsigned RHSOffset = RHS.isOnePastEnd() ? RHS.getNumElems() : RHS.getIndex();
21222122
unsigned LHSLength = (LHS.getNumElems() - 1) * LHS.elemSize();
21232123
unsigned RHSLength = (RHS.getNumElems() - 1) * RHS.elemSize();
21242124

clang/lib/AST/ByteCode/InterpBuiltin.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2505,12 +2505,8 @@ static bool interp__builtin_is_within_lifetime(InterpState &S, CodePtr OpPC,
25052505
}
25062506

25072507
// Check if we're currently running an initializer.
2508-
for (InterpFrame *Frame = S.Current; Frame; Frame = Frame->Caller) {
2509-
if (const Function *F = Frame->getFunction();
2510-
F && F->isConstructor() && Frame->getThis().block() == Ptr.block()) {
2511-
return Error(2);
2512-
}
2513-
}
2508+
if (llvm::is_contained(S.InitializingBlocks, Ptr.block()))
2509+
return Error(2);
25142510
if (S.EvaluatingDecl && Ptr.getDeclDesc()->asVarDecl() == S.EvaluatingDecl)
25152511
return Error(2);
25162512

0 commit comments

Comments
 (0)