Skip to content

Commit

Permalink
Merged master:6c733f5a132 into amd-gfx:869e2a4225c
Browse files Browse the repository at this point in the history
Local branch amd-gfx 869e2a4 [AMDGPU] Fixup use of StackPtrOffsetReg when not initialized
Remote branch master 6c733f5 Use Pseudo Instruction to carry stack probing information
  • Loading branch information
Sw authored and Sw committed Jun 2, 2020
2 parents 869e2a4 + 6c733f5 commit 078f4ef
Show file tree
Hide file tree
Showing 150 changed files with 850 additions and 594 deletions.
15 changes: 8 additions & 7 deletions clang-tools-extra/clangd/ParsedAST.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,15 +116,15 @@ class ReplayPreamble : private PPCallbacks {
// Attach preprocessor hooks such that preamble events will be injected at
// the appropriate time.
// Events will be delivered to the *currently registered* PP callbacks.
static void attach(const IncludeStructure &Includes, CompilerInstance &Clang,
static void attach(std::vector<Inclusion> Includes, CompilerInstance &Clang,
const PreambleBounds &PB) {
auto &PP = Clang.getPreprocessor();
auto *ExistingCallbacks = PP.getPPCallbacks();
// No need to replay events if nobody is listening.
if (!ExistingCallbacks)
return;
PP.addPPCallbacks(std::unique_ptr<PPCallbacks>(new ReplayPreamble(
Includes, ExistingCallbacks, Clang.getSourceManager(), PP,
std::move(Includes), ExistingCallbacks, Clang.getSourceManager(), PP,
Clang.getLangOpts(), PB)));
// We're relying on the fact that addPPCallbacks keeps the old PPCallbacks
// around, creating a chaining wrapper. Guard against other implementations.
Expand All @@ -133,10 +133,10 @@ class ReplayPreamble : private PPCallbacks {
}

private:
ReplayPreamble(const IncludeStructure &Includes, PPCallbacks *Delegate,
ReplayPreamble(std::vector<Inclusion> Includes, PPCallbacks *Delegate,
const SourceManager &SM, Preprocessor &PP,
const LangOptions &LangOpts, const PreambleBounds &PB)
: Includes(Includes), Delegate(Delegate), SM(SM), PP(PP) {
: Includes(std::move(Includes)), Delegate(Delegate), SM(SM), PP(PP) {
// Only tokenize the preamble section of the main file, as we are not
// interested in the rest of the tokens.
MainFileTokens = syntax::tokenize(
Expand Down Expand Up @@ -167,7 +167,7 @@ class ReplayPreamble : private PPCallbacks {
}

void replay() {
for (const auto &Inc : Includes.MainFileIncludes) {
for (const auto &Inc : Includes) {
const FileEntry *File = nullptr;
if (Inc.Resolved != "")
if (auto FE = SM.getFileManager().getFile(Inc.Resolved))
Expand Down Expand Up @@ -227,7 +227,7 @@ class ReplayPreamble : private PPCallbacks {
}
}

const IncludeStructure &Includes;
const std::vector<Inclusion> Includes;
PPCallbacks *Delegate;
const SourceManager &SM;
Preprocessor &PP;
Expand Down Expand Up @@ -382,7 +382,8 @@ ParsedAST::build(llvm::StringRef Filename, const ParseInputs &Inputs,
Includes = Preamble->Includes;
Includes.MainFileIncludes = Patch->preambleIncludes();
// Replay the preamble includes so that clang-tidy checks can see them.
ReplayPreamble::attach(Includes, *Clang, Preamble->Preamble.getBounds());
ReplayPreamble::attach(Patch->preambleIncludes(), *Clang,
Preamble->Preamble.getBounds());
}
// Important: collectIncludeStructure is registered *after* ReplayPreamble!
// Otherwise we would collect the replayed includes again...
Expand Down
20 changes: 20 additions & 0 deletions clang-tools-extra/clangd/unittests/ParsedASTTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,8 @@ TEST(ParsedASTTest, CollectsMainFileMacroExpansions) {
testing::UnorderedElementsAreArray(TestCase.points()));
}

MATCHER_P(WithFileName, Inc, "") { return arg.FileName == Inc; }

TEST(ParsedASTTest, ReplayPreambleForTidyCheckers) {
struct Inclusion {
Inclusion(const SourceManager &SM, SourceLocation HashLoc,
Expand Down Expand Up @@ -439,6 +441,24 @@ TEST(ParsedASTTest, ReplayPreambleForTidyCheckers) {
Code.substr(FileRange.Begin - 1, FileRange.End - FileRange.Begin + 2));
EXPECT_EQ(SkippedFiles[I].kind(), tok::header_name);
}

// Make sure replay logic works with patched preambles.
TU.Code = "";
StoreDiags Diags;
auto Inputs = TU.inputs();
auto CI = buildCompilerInvocation(Inputs, Diags);
auto EmptyPreamble =
buildPreamble(testPath(TU.Filename), *CI, Inputs, true, nullptr);
ASSERT_TRUE(EmptyPreamble);
TU.Code = "#include <a.h>";
Includes.clear();
auto PatchedAST = ParsedAST::build(testPath(TU.Filename), TU.inputs(),
std::move(CI), {}, EmptyPreamble);
ASSERT_TRUE(PatchedAST);
// Make sure includes were seen only once.
EXPECT_THAT(Includes,
ElementsAre(WithFileName(testPath("__preamble_patch__.h")),
WithFileName("a.h")));
}

TEST(ParsedASTTest, PatchesAdditionalIncludes) {
Expand Down
1 change: 0 additions & 1 deletion clang/lib/AST/Stmt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,6 @@ SourceRange Stmt::getSourceRange() const {
}

SourceLocation Stmt::getBeginLoc() const {
// llvm::errs() << "getBeginLoc() for " << getStmtClassName() << "\n";
switch (getStmtClass()) {
case Stmt::NoStmtClass: llvm_unreachable("statement without class");
#define ABSTRACT_STMT(type)
Expand Down
4 changes: 3 additions & 1 deletion clang/lib/Basic/Targets/AMDGPU.h
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,9 @@ class LLVM_LIBRARY_VISIBILITY AMDGPUTargetInfo final : public TargetInfo {
// address space has value 0 but in private and local address space has
// value ~0.
uint64_t getNullPointerValue(LangAS AS) const override {
return AS == LangAS::opencl_local ? ~0 : 0;
// FIXME: Also should handle region.
return (AS == LangAS::opencl_local || AS == LangAS::opencl_private)
? ~0 : 0;
}

void setAuxTarget(const TargetInfo *Aux) override;
Expand Down
17 changes: 15 additions & 2 deletions clang/lib/Sema/SemaExprCXX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8304,8 +8304,21 @@ ExprResult Sema::ActOnFinishFullExpr(Expr *FE, SourceLocation CC,
}

FullExpr = CorrectDelayedTyposInExpr(FullExpr.get());
if (FullExpr.isInvalid())
return ExprError();
if (FullExpr.isInvalid()) {
// Typo-correction fails, we rebuild the broken AST with the typos degraded
// to RecoveryExpr.
// FIXME: we lose source locations for RecoveryExpr, as TypoExpr doesn't
// track source locations.
struct TyposReplace : TreeTransform<TyposReplace> {
TyposReplace(Sema &SemaRef) : TreeTransform(SemaRef) {}
ExprResult TransformTypoExpr(TypoExpr *E) {
return this->SemaRef.CreateRecoveryExpr(E->getBeginLoc(),
E->getEndLoc(), {});
}
} TT(*this);

return TT.TransformExpr(FE);
}

CheckCompletedExpr(FullExpr.get(), CC, IsConstexpr);

Expand Down
19 changes: 19 additions & 0 deletions clang/test/AST/ast-dump-recovery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,25 @@ int some_func(int *);
// CHECK-NEXT: `-IntegerLiteral {{.*}} 123
// DISABLED-NOT: -RecoveryExpr {{.*}} contains-errors
int invalid_call = some_func(123);
void test_invalid_call(int s) {
// CHECK: CallExpr {{.*}} '<dependent type>' contains-errors
// CHECK-NEXT: |-UnresolvedLookupExpr {{.*}} 'some_func'
// CHECK-NEXT: |-RecoveryExpr {{.*}} <<invalid sloc>>
// CHECK-NEXT: `-BinaryOperator {{.*}} <<invalid sloc>, col:28>
// CHECK-NEXT: |-RecoveryExpr {{.*}} <<invalid sloc>>
// CHECK-NEXT: `-IntegerLiteral {{.*}} <col:28> 'int' 1
some_func(undef1, undef2+1);

// CHECK: BinaryOperator {{.*}} '<dependent type>' contains-errors '='
// CHECK-NEXT: |-DeclRefExpr {{.*}} 's'
// CHECK-NEXT: `-CallExpr {{.*}} '<dependent type>' contains-errors
// CHECK-NEXT: |-UnresolvedLookupExpr {{.*}} 'some_func'
// CHECK-NEXT: `-RecoveryExpr {{.*}} contains-errors
s = some_func(undef1);
// CHECK: `-VarDecl {{.*}} invalid var 'int'
// FIXME: preserve the broken call.
int var = some_func(undef1);
}

int ambig_func(double);
int ambig_func(float);
Expand Down
Loading

0 comments on commit 078f4ef

Please sign in to comment.