Refactoring C++ with Clang Or how to make C++ more fun than Java - - PowerPoint PPT Presentation

refactoring c with clang
SMART_READER_LITE
LIVE PREVIEW

Refactoring C++ with Clang Or how to make C++ more fun than Java - - PowerPoint PPT Presentation

Refactoring C++ with Clang Or how to make C++ more fun than Java Manuel Klimek - Google We care about... We care about... Performance We care about... Performance Productivity We care about... Performance Productivity


slide-1
SLIDE 1

Refactoring C++ with Clang

Or how to make C++ more fun than Java

Manuel Klimek - Google

slide-2
SLIDE 2

We care about...

slide-3
SLIDE 3

We care about...

  • Performance
slide-4
SLIDE 4

We care about...

  • Performance
  • Productivity
slide-5
SLIDE 5
  • Performance
  • Productivity
  • Fun

We care about...

slide-6
SLIDE 6
  • Performance
  • Productivity
  • Fun

C++ gives us...

slide-7
SLIDE 7
  • Performance ✓
  • Productivity
  • Fun

C++ gives us...

slide-8
SLIDE 8
  • Performance ✓
  • Productivity ✓
  • Fun

C++ gives us...

slide-9
SLIDE 9
  • Performance ✓
  • Productivity ✓
  • Fun ?

C++ gives us...

slide-10
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
SLIDE 11

C++ could be more fun...

slide-12
SLIDE 12

Tooling!

slide-13
SLIDE 13

Tooling!

slide-14
SLIDE 14

Tooling!

  • Correct indentation
slide-15
SLIDE 15

Tooling!

  • Correct indentation
  • Fixing style violations
slide-16
SLIDE 16

Tooling!

  • Correct indentation
  • Fixing style violations
  • Renaming variables
slide-17
SLIDE 17

Tooling!

  • Correct indentation
  • Fixing style violations
  • Renaming variables
  • Creating code structure
slide-18
SLIDE 18

Challenges...

slide-19
SLIDE 19

Challenges...

  • X-TU
slide-20
SLIDE 20

Challenges...

  • X-TU
  • Workflow Integration
slide-21
SLIDE 21

Challenges...

  • X-TU
  • Workflow Integration
  • Build Systems
slide-22
SLIDE 22

Challenges...

  • X-TU
  • Workflow Integration
  • Build Systems
  • Speed
slide-23
SLIDE 23

Tomorrowland

Clang

slide-24
SLIDE 24

Libraries Tomorrowland

Clang

slide-25
SLIDE 25

Libraries Tomorrowland

Clang

Tools

slide-26
SLIDE 26

Libraries Tomorrowland

Clang

IDE'ish Services Tools

slide-27
SLIDE 27

Libraries Tomorrowland

Clang

IDE'ish Services Editor Integration Tools

slide-28
SLIDE 28

Libraries Tomorrowland

Clang

IDE'ish Services Editor Integration Tools

slide-29
SLIDE 29

Libraries

  • Tooling

Tomorrowland

Clang

IDE'ish Services Editor Integration Tools

slide-30
SLIDE 30

Clang tooling layers

slide-31
SLIDE 31

Clang tooling layers

  • Clang Plugins
slide-32
SLIDE 32

Clang tooling layers

  • Clang Plugins
  • libClang
slide-33
SLIDE 33

Clang tooling layers

  • Clang Plugins
  • libClang
  • libTooling
slide-34
SLIDE 34

libTooling

  • Run over a string
  • Run over multiple files in a project
slide-35
SLIDE 35

bool RunToolOnCode( FrontendAction *ToolAction, Twine Code, Twine FileName);

slide-36
SLIDE 36

Libraries

  • Tooling

Tomorrowland

Clang

IDE'ish Services Editor Integration Tools

slide-37
SLIDE 37

Libraries

  • Tooling
  • Refactoring

Tomorrowland

Clang

IDE'ish Services Editor Integration Tools

slide-38
SLIDE 38

Hide ALL the complexity!

  • Apply
  • Deduplicated
  • Edits
slide-39
SLIDE 39

Libraries

  • Tooling
  • Refactoring

Tomorrowland

Clang

IDE'ish Services Editor Integration Tools

slide-40
SLIDE 40

Libraries

  • Tooling
  • Refactoring
  • ASTMatchers

Tomorrowland

Clang

IDE'ish Services Editor Integration Tools

slide-41
SLIDE 41

RAV Considered Complicated

Call(Callee(Method(HasName( "eat"))) eat(); honey.eat(); (*eat)();

slide-42
SLIDE 42

Libraries

  • Tooling
  • Refactoring
  • ASTMatchers

Tomorrowland

Clang

IDE'ish Services Editor Integration Tools

slide-43
SLIDE 43

Libraries

  • Tooling
  • Refactoring
  • ASTMatchers

Tomorrowland

Clang

IDE'ish Services Editor Integration Tools

slide-44
SLIDE 44

Libraries

  • Tooling
  • Refactoring
  • ASTMatchers

Tomorrowland

Clang

IDE'ish Services Editor Integration Tools

  • clang-format
slide-45
SLIDE 45

The Whitespace Cure

  • configurable
  • boxable
  • context sensitive
  • correct
slide-46
SLIDE 46

Libraries

  • Tooling
  • Refactoring
  • ASTMatchers

Tomorrowland

Clang

IDE'ish Services Editor Integration Tools

  • clang-format
slide-47
SLIDE 47

Libraries

  • Tooling
  • Refactoring
  • ASTMatchers

Tomorrowland

Clang

IDE'ish Services Editor Integration Tools

  • clang-format
  • clang-lint
slide-48
SLIDE 48

Phoenix rising

  • interactive automatic fixes
  • configure patterns
  • minimize false positives
slide-49
SLIDE 49

Libraries

  • Tooling
  • Refactoring
  • ASTMatchers

Tomorrowland

Clang

IDE'ish Services Editor Integration Tools

  • clang-format
  • clang-lint
slide-50
SLIDE 50

Libraries

  • Tooling
  • Refactoring
  • ASTMatchers

Tomorrowland

Clang

IDE'ish Services Editor Integration Tools

  • clang-format
  • clang-lint
  • clang-rename
slide-51
SLIDE 51

Common Code Transformations

  • autonomous and integrated
  • fast and correct
slide-52
SLIDE 52

Libraries

  • Tooling
  • Refactoring
  • ASTMatchers

Tomorrowland

Clang

IDE'ish Services Editor Integration Tools

  • clang-format
  • clang-lint
  • clang-rename
slide-53
SLIDE 53

Libraries

  • Tooling
  • Refactoring
  • ASTMatchers

Tomorrowland

Clang

IDE'ish Services Editor Integration Tools

  • clang-format
  • clang-lint
  • clang-rename
slide-54
SLIDE 54

Libraries

  • Tooling
  • Refactoring
  • ASTMatchers

Tomorrowland

Clang

IDE'ish Services

ClangD

Editor Integration Tools

  • clang-format
  • clang-lint
  • clang-rename
slide-55
SLIDE 55

ClangD manages...

  • dirty buffers
  • caches parsing
  • open RPC interface
  • build system integration
slide-56
SLIDE 56

ClangD provides...

  • fast context information
  • complete code
  • run actions
slide-57
SLIDE 57

Libraries

  • Tooling
  • Refactoring
  • ASTMatchers

Tomorrowland

Clang

IDE'ish Services

ClangD

Editor Integration Tools

  • clang-format
  • clang-lint
  • clang-rename
slide-58
SLIDE 58

Libraries

  • Tooling
  • Refactoring
  • ASTMatchers

Tomorrowland

Clang

IDE'ish Services

ClangD

Editor Integration Tools

  • clang-format
  • clang-lint
  • clang-rename
slide-59
SLIDE 59

Libraries

  • Tooling
  • Refactoring
  • ASTMatchers

Tomorrowland

Clang

IDE'ish Services

ClangD

Editor Integration

  • Emacs
  • Vim
  • Eclipse

Tools

  • clang-format
  • clang-lint
  • clang-rename
slide-60
SLIDE 60

IDE everywhere

  • command line
  • emacs, vi
  • integrate other IDEs
slide-61
SLIDE 61

Libraries

  • Tooling
  • Refactoring
  • ASTMatchers

Tomorrowland

Clang

IDE'ish Services

ClangD

Editor Integration

  • Emacs
  • Vim
  • Eclipse

Tools

  • clang-format
  • clang-lint
  • clang-rename
slide-62
SLIDE 62

Libraries

  • Tooling
  • Refactoring
  • ASTMatchers

Tomorrowland

Clang

IDE'ish Services

ClangD

Editor Integration

  • Emacs
  • Vim
  • Eclipse

Tools

  • clang-format
  • clang-lint
  • clang-rename
slide-63
SLIDE 63

Where are we?

  • Libraries... in progress.
  • Tools... early spikes.
  • ClangD... entering design phase.
  • Editor integration...
slide-64
SLIDE 64

What's next?

You!

slide-65
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