SLIDE 1 Refactoring C++ with Clang
Or how to make C++ more fun than Java
Manuel Klimek - Google
SLIDE 2
We care about...
SLIDE 5
- Performance
- Productivity
- Fun
We care about...
SLIDE 6
- Performance
- Productivity
- Fun
C++ gives us...
SLIDE 7
- Performance ✓
- Productivity
- Fun
C++ gives us...
SLIDE 8
- Performance ✓
- Productivity ✓
- Fun
C++ gives us...
SLIDE 9
- Performance ✓
- Productivity ✓
- Fun ?
C++ gives us...
SLIDE 10
Subject: [PATCH] Awesome new feature On Thu, March 8, 2011 PedanticGuy wrote: > On Wed, March 7, 2011 NewContributor wrote: > + void DoSomethingAwesome(Cats cats); ALL your methods are capitalized incorrectly... Please fix. Thx.
SLIDE 11
C++ could be more fun...
SLIDE 12
Tooling!
SLIDE 13
Tooling!
SLIDE 15 Tooling!
- Correct indentation
- Fixing style violations
SLIDE 16 Tooling!
- Correct indentation
- Fixing style violations
- Renaming variables
SLIDE 17 Tooling!
- Correct indentation
- Fixing style violations
- Renaming variables
- Creating code structure
SLIDE 18
Challenges...
SLIDE 20 Challenges...
- X-TU
- Workflow Integration
SLIDE 21 Challenges...
- X-TU
- Workflow Integration
- Build Systems
SLIDE 22 Challenges...
- X-TU
- Workflow Integration
- Build Systems
- Speed
SLIDE 23
Tomorrowland
Clang
SLIDE 24
Libraries Tomorrowland
Clang
SLIDE 25
Libraries Tomorrowland
Clang
Tools
SLIDE 26
Libraries Tomorrowland
Clang
IDE'ish Services Tools
SLIDE 27
Libraries Tomorrowland
Clang
IDE'ish Services Editor Integration Tools
SLIDE 28
Libraries Tomorrowland
Clang
IDE'ish Services Editor Integration Tools
SLIDE 29 Libraries
Tomorrowland
Clang
IDE'ish Services Editor Integration Tools
SLIDE 30
Clang tooling layers
SLIDE 31 Clang tooling layers
SLIDE 32 Clang tooling layers
SLIDE 33 Clang tooling layers
- Clang Plugins
- libClang
- libTooling
SLIDE 34 libTooling
- Run over a string
- Run over multiple files in a project
SLIDE 35
bool RunToolOnCode( FrontendAction *ToolAction, Twine Code, Twine FileName);
SLIDE 36 Libraries
Tomorrowland
Clang
IDE'ish Services Editor Integration Tools
SLIDE 37 Libraries
Tomorrowland
Clang
IDE'ish Services Editor Integration Tools
SLIDE 38 Hide ALL the complexity!
SLIDE 39 Libraries
Tomorrowland
Clang
IDE'ish Services Editor Integration Tools
SLIDE 40 Libraries
- Tooling
- Refactoring
- ASTMatchers
Tomorrowland
Clang
IDE'ish Services Editor Integration Tools
SLIDE 41
RAV Considered Complicated
Call(Callee(Method(HasName( "eat"))) eat(); honey.eat(); (*eat)();
SLIDE 42 Libraries
- Tooling
- Refactoring
- ASTMatchers
Tomorrowland
Clang
IDE'ish Services Editor Integration Tools
SLIDE 43 Libraries
- Tooling
- Refactoring
- ASTMatchers
Tomorrowland
Clang
IDE'ish Services Editor Integration Tools
SLIDE 44 Libraries
- Tooling
- Refactoring
- ASTMatchers
Tomorrowland
Clang
IDE'ish Services Editor Integration Tools
SLIDE 45 The Whitespace Cure
- configurable
- boxable
- context sensitive
- correct
SLIDE 46 Libraries
- Tooling
- Refactoring
- ASTMatchers
Tomorrowland
Clang
IDE'ish Services Editor Integration Tools
SLIDE 47 Libraries
- Tooling
- Refactoring
- ASTMatchers
Tomorrowland
Clang
IDE'ish Services Editor Integration Tools
SLIDE 48 Phoenix rising
- interactive automatic fixes
- configure patterns
- minimize false positives
SLIDE 49 Libraries
- Tooling
- Refactoring
- ASTMatchers
Tomorrowland
Clang
IDE'ish Services Editor Integration Tools
SLIDE 50 Libraries
- Tooling
- Refactoring
- ASTMatchers
Tomorrowland
Clang
IDE'ish Services Editor Integration Tools
- clang-format
- clang-lint
- clang-rename
SLIDE 51 Common Code Transformations
- autonomous and integrated
- fast and correct
SLIDE 52 Libraries
- Tooling
- Refactoring
- ASTMatchers
Tomorrowland
Clang
IDE'ish Services Editor Integration Tools
- clang-format
- clang-lint
- clang-rename
SLIDE 53 Libraries
- Tooling
- Refactoring
- ASTMatchers
Tomorrowland
Clang
IDE'ish Services Editor Integration Tools
- clang-format
- clang-lint
- clang-rename
SLIDE 54 Libraries
- Tooling
- Refactoring
- ASTMatchers
Tomorrowland
Clang
IDE'ish Services
ClangD
Editor Integration Tools
- clang-format
- clang-lint
- clang-rename
SLIDE 55 ClangD manages...
- dirty buffers
- caches parsing
- open RPC interface
- build system integration
SLIDE 56 ClangD provides...
- fast context information
- complete code
- run actions
SLIDE 57 Libraries
- Tooling
- Refactoring
- ASTMatchers
Tomorrowland
Clang
IDE'ish Services
ClangD
Editor Integration Tools
- clang-format
- clang-lint
- clang-rename
SLIDE 58 Libraries
- Tooling
- Refactoring
- ASTMatchers
Tomorrowland
Clang
IDE'ish Services
ClangD
Editor Integration Tools
- clang-format
- clang-lint
- clang-rename
SLIDE 59 Libraries
- Tooling
- Refactoring
- ASTMatchers
Tomorrowland
Clang
IDE'ish Services
ClangD
Editor Integration
Tools
- clang-format
- clang-lint
- clang-rename
SLIDE 60 IDE everywhere
- command line
- emacs, vi
- integrate other IDEs
SLIDE 61 Libraries
- Tooling
- Refactoring
- ASTMatchers
Tomorrowland
Clang
IDE'ish Services
ClangD
Editor Integration
Tools
- clang-format
- clang-lint
- clang-rename
SLIDE 62 Libraries
- Tooling
- Refactoring
- ASTMatchers
Tomorrowland
Clang
IDE'ish Services
ClangD
Editor Integration
Tools
- clang-format
- clang-lint
- clang-rename
SLIDE 63 Where are we?
- Libraries... in progress.
- Tools... early spikes.
- ClangD... entering design phase.
- Editor integration...
SLIDE 64
What's next?
You!
SLIDE 65 References
Discussions, ideas: Bring them up on cfe-dev@cs.uiuc.edu Tooling Branch (beware, spiky) cfe/branches/tooling Clang MapReduce -- Automatic C++ Refactoring at Google Scale http://llvm.org/devmtg/2011-11/#talk2