How do I identify which CPU a MacBook uses? I'd like to identify which CPU this notebook is using, in terms of code names such as "Ivy Bridge" and "Haswell". The little Apple logo in the upper left shows some information, but not this.
First off, you are not going to get the processor microarchitecture name (Broadwell, Sandy Lake, Ivy Bridge, etc.) because it's not a prominent branding scheme for the Intel processors.  Contrast that with Apple, the marketing department chooses to actively market the code names of their operatings systems (Mavericks, Yosemite, El Capitan).  It's a marketing convention, not a technical one.
For a list of all Intel Processors and their codenames, architectures and specs, Wikipedia's List of Intel Microprocessors has a good page.
So, to answer this question, I am going to provide three methods to find out what CPU you have, the first two, which should be good for most users, and a third method in which you can determine the microarchitecture number so you can look it up on Intel's support site.  You can &quot;jump&quot; to the section that applies to you.

About this Mac (general CPU info)
System Profiler (general CPU info)
Terminal (detailed CPU info)


About this Mac
Clicking on the Apple symbol at the top of your screen, select About this Mac

You will get a screen that gives you an overview of your system.  Your processor will be listed here.


System Profiler
Clicking on the button marked System Report... (green arrow) you get a complete profile of your system.  On the first page, it will give you more detailed info about your machine, including processor info

Terminal
I am a fan of Terminal in general.  Pretty much everything you see in the GUI in OS X can be accessed quicker and more accurately through the command line, IMHO.
To get the exact CPU model including the microarchitecture number, in Terminal, execute the following command:
sysctl -n machdep.cpu.brand_string

You will get the exact processor that you are using.  For instance, on my iMac, it the command above responds with:
Intel(R) Core(TM) i7-3770 CPU @ 3.40GHz
You can then do a search for i7-3770 and pull up the code name and specs.
Just for reference, you can use the Terminal command:
system_profiler SPHardwareDataType

and get a result that looks just like the screen that I posted in the second section, System Profiler:
Hardware Overview:

  Model Name: iMac
  Model Identifier: iMac13,2
  Processor Name: Intel Core i7
  Processor Speed: 3.4 GHz
  Number of Processors: 1
  Total Number of Cores: 4
  L2 Cache (per Core): 256 KB
  L3 Cache: 8 MB
  Memory: 32 GB
  Boot ROM Version: IM131.010A.B09
  SMC Version (system): 2.11f14
  Serial Number (system): XXXXXXXXXXXXXXXXXXX
  Hardware UUID: XXXXXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXX

(Credit to dante12 below)
So, if you needed your CPU or more commonly, your Model Identifier, you can use the same command coupled with grep.
system_profiler SPHardwareDataType | grep Identifier

It responds back with
  Model Identifier: iMac13,2