For Whom the Bell Tolls is about the Spanish Civil War, and the Spanish Civil War is all about politics: it's a conflict between the leftist "Republic" and the fascist Nationalists. All of the characters the novel focuses on fight for the Republic, some of them with a zeal which borders on the religious. Yet what the Republic stands for is somewhat up for grabs: it's a troubled coalition of Communists, anarchists, and those who simply believe in "freedom" or "the people." The optimism or idealism felt by some characters is sharply contrasted with the reality of Republican politics – constant lying, infighting, control by foreigners. The protagonist's loss of a naive idealism is a major step in his "education."
While Robert Jordan might be classified as an idealist because he believes the Republican cause is straightforwardly the cause of "freedom," his position makes sense when it is considered that the loss of the Republicans would mean the victory of the fascists.
Even if he does not consider himself to be a communist, Robert Jordan is still a communist insofar as he is willing to serve the Communist Party without objection to its more doubtful practices.