Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/arduino.cc/builder/ctags/ctags_parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ func removeDuplicate(tags []*types.CTag) {
definedPrototypes := make(map[string]bool)

for _, tag := range tags {
if !definedPrototypes[tag.Prototype] {
if !definedPrototypes[tag.Prototype] && tag.SkipMe == false {
definedPrototypes[tag.Prototype] = true
} else {
tag.SkipMe = true
Expand Down
52 changes: 52 additions & 0 deletions src/arduino.cc/builder/test/ctags_to_prototypes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,13 @@
package test

import (
"arduino.cc/builder"
"arduino.cc/builder/constants"
"arduino.cc/builder/ctags"
"arduino.cc/builder/types"
"github.com/stretchr/testify/require"
"io/ioutil"
"os"
"path/filepath"
"testing"
)
Expand Down Expand Up @@ -459,3 +462,52 @@ func TestCTagsToPrototypesFunctionPointers(t *testing.T) {

require.Equal(t, 2, ctx.PrototypesLineWhereToInsert)
}

func TestCTagsRunnerSketchWithClassFunction(t *testing.T) {
DownloadCoresAndToolsAndLibraries(t)

sketchLocation := Abs(t, filepath.Join("sketch_class_function", "sketch_class_function.ino"))

ctx := &types.Context{
HardwareFolders: []string{filepath.Join("..", "hardware"), "hardware", "downloaded_hardware"},
ToolsFolders: []string{"downloaded_tools"},
BuiltInLibrariesFolders: []string{"downloaded_libraries"},
OtherLibrariesFolders: []string{"libraries"},
SketchLocation: sketchLocation,
FQBN: "arduino:avr:leonardo",
ArduinoAPIVersion: "10600",
Verbose: true,
}

buildPath := SetupBuildPath(t, ctx)
defer os.RemoveAll(buildPath)

commands := []types.Command{

&builder.ContainerSetupHardwareToolsLibsSketchAndProps{},

&builder.ContainerMergeCopySketchFiles{},

&builder.ContainerFindIncludes{},

&builder.PrintUsedLibrariesIfVerbose{},
&builder.WarnAboutArchIncompatibleLibraries{},
&builder.CTagsTargetFileSaver{Source: &ctx.Source, TargetFileName: constants.FILE_CTAGS_TARGET},
&ctags.CTagsRunner{},
&ctags.CTagsParser{},
&CollectCtagsFromPreprocSource{},
&ctags.CTagsToPrototypes{},
}

for _, command := range commands {
err := command.Run(ctx)
NoError(t, err)
}

prototypes := ctx.Prototypes

require.Equal(t, 3, len(prototypes))
require.Equal(t, "void setup();", prototypes[0].Prototype)
require.Equal(t, "void loop();", prototypes[1].Prototype)
require.Equal(t, "void asdf();", prototypes[2].Prototype)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
class test {
void asdf() {}
};
void setup() {
asdf();
}
void loop() {}
void asdf() {}