Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add scafolding to play around with and bring up the code rewriter.
llvm-svn: 42855
- Loading branch information
Showing
3 changed files
with
51 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
//===--- RewriteTest.cpp - Playground for the code rewriter ---------------===// | ||
// | ||
// The LLVM Compiler Infrastructure | ||
// | ||
// This file was developed by Chris Lattner and is distributed under the | ||
// University of Illinois Open Source License. See LICENSE.TXT for details. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// Hacks and fun related to the code rewriter. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#include "ASTConsumers.h" | ||
#include "clang/AST/AST.h" | ||
#include "clang/AST/ASTConsumer.h" | ||
|
||
using namespace clang; | ||
|
||
|
||
namespace { | ||
class ASTViewer : public ASTConsumer { | ||
SourceManager *SM; | ||
public: | ||
void Initialize(ASTContext &Context, unsigned MainFileID) { | ||
SM = &Context.SourceMgr; | ||
} | ||
|
||
virtual void HandleTopLevelDecl(Decl *D); | ||
}; | ||
} | ||
|
||
ASTConsumer *clang::CreateCodeRewriterTest() { return new ASTViewer(); } | ||
|
||
|
||
|
||
|
||
void ASTViewer::HandleTopLevelDecl(Decl *D) { | ||
if (NamedDecl *ND = dyn_cast<NamedDecl>(D)) | ||
if (ND->getName()) | ||
printf("%s\n", ND->getName()); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters