internal/importers/objc: fix parsing of newer clang output

Two things broke the clang ast dump parser:

- clang -cc1 didn't parse headers in iPhone mode automatically anymore.
  Add the -triple argument to force it.
- Source positions in the dumps can now contain <scratch space>.

Change-Id: I5d561f781355021f60c94d59e20bf1c1eee76d2a
Reviewed-on: https://go-review.googlesource.com/c/159678
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
diff --git a/internal/importers/objc/objc.go b/internal/importers/objc/objc.go
index f729588..61cd56b 100644
--- a/internal/importers/objc/objc.go
+++ b/internal/importers/objc/objc.go
@@ -412,7 +412,7 @@
 // file Module.framework/Headers/Module.h contains every declaration.
 func importModule(sdkPath, module string, identifiers []string, typeMap map[string]*Named) ([]*Named, error) {
 	hFile := fmt.Sprintf(sdkPath+frameworksPath+"%s.framework/Headers/%[1]s.h", module)
-	clang := exec.Command("xcrun", "--sdk", "iphonesimulator", "clang", "-cc1", "-isysroot", sdkPath, "-ast-dump", "-fblocks", "-fobjc-arc", "-x", "objective-c", hFile)
+	clang := exec.Command("xcrun", "--sdk", "iphonesimulator", "clang", "-cc1", "-triple", "x86_64-apple-ios8.0.0-simulator", "-isysroot", sdkPath, "-ast-dump", "-fblocks", "-fobjc-arc", "-x", "objective-c", hFile)
 	out, err := clang.CombinedOutput()
 	if err != nil {
 		return nil, fmt.Errorf("clang failed to parse module: %v: %s", err, out)
@@ -774,9 +774,17 @@
 		p.decl = p.decl[len(invPref):]
 		return
 	}
-	// line:17:2, col:18 or, a file location:
-	// /.../UIKit.framework/Headers/UISelectionFeedbackGenerator.h:16:1
-	loc := p.scanWord()
+	var loc string
+	const scrPref = "<scratch space>"
+	if strings.HasPrefix(p.decl, scrPref) {
+		// <scratch space>:130:1
+		p.decl = p.decl[len(scrPref):]
+		loc = "line" + p.scanWord()
+	} else {
+		// line:17:2, col:18 or, a file location:
+		// /.../UIKit.framework/Headers/UISelectionFeedbackGenerator.h:16:1
+		loc = p.scanWord()
+	}
 	locs := strings.SplitN(loc, ":", 2)
 	if len(locs) != 2 && len(locs) != 3 {
 		panic(fmt.Errorf("invalid source position: %q", loc))