Skip to content

Commit

Permalink
Clean up after merging latest sources (#603)
Browse files Browse the repository at this point in the history
Cherry-picked from commit c9f834e

    This addresses issue #601.
    - Clean up PointerTypeLoc class.   The merge introduced a new base class.  We had redundant methods on the subclass and some methods on the subclass that needed to be moved to the base class.
    - Fix compiler warnings about fall-through.
    - Remove some commented out code that was left behind.
    - Update directions for merging latest sources.
  • Loading branch information
dtarditi authored and Mandeep Singh Grang committed Sep 27, 2019
1 parent 1f9cbb6 commit c1d0b76
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 69 deletions.
113 changes: 74 additions & 39 deletions clang/docs/checkedc/Update-to-latest-LLVM-sources.md
Original file line number Diff line number Diff line change
@@ -1,69 +1,104 @@
# Instructions for updating to the latest LLVM/clang sources

We are staying in sync with the LLVM/clang mainline sources. The baseline branch is a pristine copy of clang/LLVM sources.
We periodically update the baseline branch and then push the changes to other branches
We are staying in sync with the LLVM/clang mainline sources. The baseline branch is a pristine copy of
LLVM/clang sources. We periodically update the baseline branch and then push the changes to other branches

## Update your local baseline branches to the latest sources
To update the baseline branch to the latest sourcess, make sure you have personal forks of the Checked C LLVM and clang repos.
Clone these forks to your local machine. Then create remotes to the mirrored Github repos that contain the updates sources
for LLVM and clang. Go to your LLVM repo and do:
The first step is to create updated baseline branches:
1. Create new branches of your local baseline branches (we suggest creating new
branches so that you can run automated testing. You'll need new branches
that you can push to GitHub).
2. Update those branches to the latest sources.
3. Run testing on those branches to make sure things are stable.

git remote add mirror https://github.com/llvm-mirror/llvm
The second step is to create updated master branches:
1. Create branches of your updated baseline branches.
2. Merge changes from the Checked C master branches into those branches.
3. Fix merge conflicts and run testing. You will likely need to fix some issues
and re-run testing until all issues are fixed.

Set the upstream branch to the master llvm branch:
The third step is to merge your changes back into your baseline and master branches.

git branch --set-upstream baseline mirror/llvm
## Create updated branches of your baseline branches

You can then pull changes from the main repo into your local repo:
First create remotes to the mirrored GitHub repos that contain the updated sources
for LLVM and clang. Go to your LLVM repo and do:

git pull mirror baseline
git remote add mirror https://github.com/llvm-mirror/llvm

Then branch your baseline branch and merge changes into it:

git checkout baseline
git checkout -b updated-baseline
git pull mirror master

Repeat the process for your clang repo:

git remote add mirror https://github.com/llvm-mirror/clang
git branch --set-upstream baseline mirror/clang
git pull mirror baseline

git checkout baseline
git checkout -b updated-baseline
git pull mirror master

## Ensure the clang and LLVM sources are synchronized
The sources are being pulled from multiple repos that are mirrors of SVN repositories.
The sources need for LLVM and clang may be out of sync - for example, the mirrors may not be in sync or a change may
be checked in after pulling from one of the repos.

You need to make sure that source are in sync. The Git mirror commits have the SVN change number embedded in them and the
SVN change number is consistent across SVN repos for clang and LLVM. You can examine that recent change log for clang and LLVM and find changes that are in
sync according to the SVN number (there may be gaps in the numbering because a change may only affect on repo). For each Git repo, note the Git commit (the first 8 or so digits of the hash)
LLVM has unified its projects into one repo. However, we have not migrated our
repos into one repo yet. This means that our sources are being
pulled from partial mirrors of a unifed repo. You need to make sure that the
changes are in sync. The pace of commits is fast enough that a change that
causes a build break could be introduced between syncing.

For each Git repo, make *sure* that you change to the baseline branch:

git checkout baseline

Then do
While the LLVM ecosystem is migrating, you can look at the SVN IDs in the
upstream git repo commits to see if you've gotten out-of-sync. If the
changes are not very close, for each of your branched baselines
)updated-baseline in the above example), use

git reset --hard commit-number, where commit-number is the Git commit.

## Update the baseline branch on Github
## Run testing on your branched baseline branches.

You can run testing locally or push your branched baseline branches to GitHub
and use automated testing. This will show you whether there are any unexpected
failures in your baseline branch.

If you use automated testing, make sure to clean the build directory first.
Enough changes will likely have accumulated that things may go wrong without doing
that first.

## Branch your new baseline branches and merge master changes

You can now branch your baseline branches to create a new master branch:

git checkout -b updated-master
git merge master

You will very likely have merge conflicts and some test failures. The test
failures usually stem from incorrect merges or Checked C-specific data not being
initialized by new or changed constructor methods.

You will then need to build and run tests to establish test baselines. Assuming that the tests results are good,
you can push them to your personal Github forks:
You may also need to pick up changes from LLVM/clang for fixes to any unexpected
baseline failures.

git push origin baseline
You can push your updated master branches up to GitHub for automated
testing. If you haven't cleaned the build directory as described earlier,
make sure you do that.

You can then issue pull requests to pull the changes into the Microsift Github repos.
You'll want to run automated tests on Linux and Windows x86/x64, as well as
Linux LNT tests. You may find in some cases that tests need to be updated
based on new warnings or slightly different compiler behavior.

## Update the master branch.
## Merge your branched baseline and master branches

After you have updated the baseline branch, you can update the master branch. Change to each repo and then do:
Once all testing is passing, you can merge your branches back into
your baseline and master branches.

git checkout master
git merge baseline

Set up the build system and compile. Fix any issues that you encounter.
git checkout baseline
git merge updated-baseline
git checkout master
git merge updated-master

Then run tests. We have added tests for Checked C to the clang master branch, so these additional tests need to be taken
into account during testing. Make sure the code passes the following tests:
## Push the updated branches to GitHub

- The same tests as the baseline branch, _plus_ the Checked C specific tests for clang in the master branch.
- The Checked C languages tests for the Checked C project.
The changes will be extensive enough that you don't want to do a pull request
on GitHub. Just push the branches up to GitHub.

Once the tests are passing, push the changes up to a personal Github fork and issue a pull request.
38 changes: 10 additions & 28 deletions clang/include/clang/AST/TypeLoc.h
Original file line number Diff line number Diff line change
Expand Up @@ -1201,10 +1201,18 @@ class PointerLikeTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc, Derived,
this->getLocalData()->StarLoc = Loc;
}

SourceLocation getRightSymLoc() const {
return this->getLocalData()->RightSymLoc;
}

void setRightSymLoc(SourceLocation Loc) {
this->getLocalData()->RightSymLoc = Loc;
}

SourceLocation getKWLoc() const {
return this->getLocalData()->KWLoc;
}

void setKWLoc(SourceLocation Loc) {
this->getLocalData()->KWLoc = Loc;
}
Expand Down Expand Up @@ -1242,38 +1250,12 @@ class PointerTypeLoc : public PointerLikeTypeLoc<PointerTypeLoc,
setKWLoc(Loc);
}

SourceLocation getKWLoc() const {
return this->getLocalData()->KWLoc;
}
void setKWLoc(SourceLocation Loc) {
this->getLocalData()->KWLoc = Loc;
}

SourceLocation getLeftSymLoc() const {
return this->getLocalData()->StarLoc;
return getSigilLoc();
}

void setLeftSymLoc(SourceLocation Loc) {
this->getLocalData()->StarLoc = Loc;
}

SourceLocation getRightSymLoc() const {
return this->getLocalData()->RightSymLoc;
}

void setRightSymLoc(SourceLocation Loc) {
this->getLocalData()->RightSymLoc = Loc;
}

// CheckedC : do we need this?
SourceRange getBracketsRange() const {
return SourceRange(getLeftSymLoc(), getRightSymLoc());
}

// CheckedC : do we need this?
void setParensRange(SourceRange Range) {
setLeftSymLoc(Range.getBegin());
setRightSymLoc(Range.getEnd());
setSigilLoc(Loc);
}

SourceRange getLocalSourceRange() const {
Expand Down
1 change: 0 additions & 1 deletion clang/lib/CodeGen/CGBuiltin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
#include "clang/Basic/TargetInfo.h"
#include "clang/CodeGen/CGFunctionInfo.h"
#include "llvm/ADT/SmallPtrSet.h"
// #include "clang/Sema/SemaDiagnostic.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/IR/CallSite.h"
#include "llvm/IR/DataLayout.h"
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/Sema/SemaBounds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -876,7 +876,7 @@ namespace {
ArrLValue);
return ExpandToRange(Base, CBE);
} else
CreateBoundsAlwaysUnknown();
return CreateBoundsAlwaysUnknown();
}
default:
return CreateBoundsAlwaysUnknown();
Expand Down
1 change: 1 addition & 0 deletions clang/tools/libclang/CXCursor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -711,6 +711,7 @@ CXCursor cxcursor::MakeCXCursor(const Stmt *S, const Decl *Parent,
break;
case Stmt::OMPTargetTeamsDistributeSimdDirectiveClass:
K = CXCursor_OMPTargetTeamsDistributeSimdDirective;
break;

// For now, do not expose Checked C extensions.
case Stmt::PositionalParameterExprClass:
Expand Down

0 comments on commit c1d0b76

Please sign in to comment.